tor-browser

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

test_bug401153.js (1540B)


      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 
      6 var MANIFESTS = [do_get_file("data/test_bug401153.manifest")];
      7 
      8 registerManifests(MANIFESTS);
      9 
     10 const { updateAppInfo } = ChromeUtils.importESModule(
     11  "resource://testing-common/AppInfo.sys.mjs"
     12 );
     13 updateAppInfo({
     14  name: "XPCShell",
     15  ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
     16  version: "5",
     17  platformVersion: "1.9",
     18 });
     19 
     20 var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
     21  Ci.nsIChromeRegistry
     22 );
     23 chromeReg.checkForNewChrome();
     24 
     25 var rph = Services.io
     26  .getProtocolHandler("resource")
     27  .QueryInterface(Ci.nsIResProtocolHandler);
     28 
     29 function test_succeeded_mapping(namespace, target) {
     30  try {
     31    Assert.ok(rph.hasSubstitution(namespace));
     32    var uri = Services.io.newURI("resource://" + namespace);
     33    dump(
     34      "### checking for " + target + ", getting " + rph.resolveURI(uri) + "\n"
     35    );
     36    Assert.equal(rph.resolveURI(uri), target);
     37  } catch (ex) {
     38    dump(ex + "\n");
     39    do_throw(namespace);
     40  }
     41 }
     42 
     43 function test_failed_mapping(namespace) {
     44  Assert.ok(!rph.hasSubstitution(namespace));
     45 }
     46 
     47 function run_test() {
     48  var data = Services.io.newFileURI(do_get_file("data")).spec;
     49  test_succeeded_mapping("test1", data + "test1/");
     50  test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources/");
     51  test_failed_mapping("test4");
     52  test_succeeded_mapping("test5", data + "test5/");
     53 }