tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug597702.js (1128B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 const { NetUtil } = ChromeUtils.importESModule(
      6  "resource://gre/modules/NetUtil.sys.mjs"
      7 );
      8 
      9 // Check that reading non existant inner jars results in the right error
     10 
     11 function run_test() {
     12  var file = do_get_file("data/test_bug597702.zip");
     13  var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
     14  var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello";
     15  var badSpec = "jar:" + outerJarBase + "jar_that_isnt_in_the.jar!/hello";
     16  var goodChannel = NetUtil.newChannel({
     17    uri: goodSpec,
     18    loadUsingSystemPrincipal: true,
     19  });
     20  var badChannel = NetUtil.newChannel({
     21    uri: badSpec,
     22    loadUsingSystemPrincipal: true,
     23  });
     24 
     25  try {
     26    goodChannel.open();
     27  } catch (e) {
     28    do_throw("Failed to open file in inner jar");
     29  }
     30 
     31  try {
     32    badChannel.open();
     33    do_throw("Failed to report that file doesn't exist");
     34  } catch (e) {
     35    Assert.equal(e.name, "NS_ERROR_FILE_NOT_FOUND");
     36  }
     37 }