toolkit/devtools/server/tests/unit/test_sourcemaps-06.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 that we can load sources whose content is embedded in the
     6  * "sourcesContent" field of a source map.
     7  */
     9 var gDebuggee;
    10 var gClient;
    11 var gThreadClient;
    13 Components.utils.import("resource:///modules/devtools/SourceMap.jsm");
    15 function run_test()
    16 {
    17   initTestDebuggerServer();
    18   gDebuggee = addTestGlobal("test-source-map");
    19   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    20   gClient.connect(function() {
    21     attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) {
    22       gThreadClient = aThreadClient;
    23       test_source_content();
    24     });
    25   });
    26   do_test_pending();
    27 }
    29 function test_source_content()
    30 {
    31   let numNewSources = 0;
    33   gClient.addListener("newSource", function _onNewSource(aEvent, aPacket) {
    34     if (++numNewSources !== 3) {
    35       return;
    36     }
    37     gClient.removeListener("newSource", _onNewSource);
    39     gThreadClient.getSources(function (aResponse) {
    40       do_check_true(!aResponse.error, "Should not get an error");
    42       testContents(aResponse.sources, () => {
    43         finishClient(gClient);
    44       });
    45     });
    46   });
    48   let node = new SourceNode(null, null, null, [
    49     new SourceNode(1, 0, "a.js", "function a() { return 'a'; }\n"),
    50     new SourceNode(1, 0, "b.js", "function b() { return 'b'; }\n"),
    51     new SourceNode(1, 0, "c.js", "function c() { return 'c'; }\n"),
    52   ]);
    54   node.setSourceContent("a.js", "content for http://example.com/www/js/a.js");
    55   node.setSourceContent("b.js", "content for http://example.com/www/js/b.js");
    56   node.setSourceContent("c.js", "content for http://example.com/www/js/c.js");
    58   let { code, map } = node.toStringWithSourceMap({
    59     file: "abc.js"
    60   });
    62   code += "//# sourceMappingURL=data:text/json;base64," + btoa(map.toString());
    64   Components.utils.evalInSandbox(code, gDebuggee, "1.8",
    65                                  "http://example.com/www/js/abc.js", 1);
    66 }
    68 function testContents(aSources, aCallback) {
    69   if (aSources.length === 0) {
    70     aCallback();
    71     return;
    72   }
    74   let source = aSources[0];
    75   let sourceClient = gThreadClient.source(aSources[0]);
    77   sourceClient.source((aResponse) => {
    78     do_check_true(!aResponse.error,
    79                   "Should not get an error loading the source from sourcesContent");
    81     let expectedContent = "content for " + source.url;
    82     do_check_eq(aResponse.source, expectedContent,
    83                 "Should have the expected source content");
    85     testContents(aSources.slice(1), aCallback);
    86   });
    87 }

mercurial