addon-sdk/test/browser_sdk_loader_js_modules.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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