test_bug1940027_embedded_null.js (736B)
1 // Should report file not found on non-existent files 2 3 const { NetUtil } = ChromeUtils.importESModule( 4 "resource://gre/modules/NetUtil.sys.mjs" 5 ); 6 const path = "data/uncompressed.zip"; 7 8 function run_test() { 9 var spec = "jar:" + Services.io.newFileURI(do_get_file(path)).spec + "!/"; 10 var channel = NetUtil.newChannel({ 11 uri: spec + "hello", 12 loadUsingSystemPrincipal: true, 13 }); 14 let stream = channel.open(); 15 ok(stream); 16 stream.close(); 17 18 Assert.throws( 19 () => { 20 channel = NetUtil.newChannel({ 21 uri: spec + "hello%00.js", 22 loadUsingSystemPrincipal: true, 23 }); 24 channel.open(); 25 }, 26 /NS_ERROR_FILE_NOT_FOUND/, 27 "An embedded null must not truncate the path being loaded" 28 ); 29 }