toolkit/devtools/server/tests/unit/test_sourcemaps-01.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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Check basic source map integration with the "newSource" packet in the RDP.
     6  */
     8 var gDebuggee;
     9 var gClient;
    10 var gThreadClient;
    12 Components.utils.import('resource:///modules/devtools/SourceMap.jsm');
    14 function run_test()
    15 {
    16   initTestDebuggerServer();
    17   gDebuggee = addTestGlobal("test-source-map");
    18   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    19   gClient.connect(function() {
    20     attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) {
    21       gThreadClient = aThreadClient;
    22       test_simple_source_map();
    23     });
    24   });
    25   do_test_pending();
    26 }
    28 function test_simple_source_map()
    29 {
    30   // Because we are source mapping, we should be notified of a.js, b.js, and
    31   // c.js as sources, and shouldn't receive abc.js or test_sourcemaps-01.js.
    32   let expectedSources = new Set(["http://example.com/www/js/a.js",
    33                                  "http://example.com/www/js/b.js",
    34                                  "http://example.com/www/js/c.js"]);
    36   gClient.addListener("newSource", function _onNewSource(aEvent, aPacket) {
    37     do_check_eq(aEvent, "newSource");
    38     do_check_eq(aPacket.type, "newSource");
    39     do_check_true(!!aPacket.source);
    41     do_check_true(expectedSources.has(aPacket.source.url),
    42                   "The source url should be one of our original sources.");
    43     expectedSources.delete(aPacket.source.url);
    45     if (expectedSources.size === 0) {
    46       gClient.removeListener("newSource", _onNewSource);
    47       finishClient(gClient);
    48     }
    49   });
    51   let { code, map } = (new SourceNode(null, null, null, [
    52     new SourceNode(1, 0, "a.js", "function a() { return 'a'; }\n"),
    53     new SourceNode(1, 0, "b.js", "function b() { return 'b'; }\n"),
    54     new SourceNode(1, 0, "c.js", "function c() { return 'c'; }\n"),
    55   ])).toStringWithSourceMap({
    56     file: "abc.js",
    57     sourceRoot: "http://example.com/www/js/"
    58   });
    60   code += "//# sourceMappingURL=data:text/json;base64," + btoa(map.toString());
    62   Components.utils.evalInSandbox(code, gDebuggee, "1.8",
    63                                  "http://example.com/www/js/abc.js", 1);
    64 }

mercurial