addon-sdk/test/browser_sdk_loader_js_modules.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 function test () {
     2   let loader = makeLoader();
     3   let module = Module("./main", gTestPath);
     4   let require = Require(loader, module);
     6   try {
     7     let Model = require("./cant-find-me");
     8     ok(false, "requiring a JS module that doesn't exist should throw");
     9   }
    10   catch (e) {
    11     ok(e, "requiring a JS module that doesn't exist should throw");
    12   }
    15   /*
    16    * Relative resource:// URI of JS
    17    */
    19   let { square } = require("./math");
    20   is(square(5), 25, "loads relative URI of JS");
    22   /*
    23    * Absolute resource:// URI of JS
    24    */
    26   let { has } = require("resource://gre/modules/commonjs/sdk/util/array");
    27   let testArray = ['rock', 'paper', 'scissors'];
    29   ok(has(testArray, 'rock'), "loads absolute resource:// URI of JS");
    30   ok(!has(testArray, 'dragon'), "loads absolute resource:// URI of JS");
    32   finish();
    33 }

mercurial