toolkit/devtools/server/tests/unit/test_sourcemaps-02.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 "sources" 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.addOneTimeListener("paused", function (aEvent, aPacket) {
    37     gThreadClient.getSources(function (aResponse) {
    38       do_check_true(!aResponse.error, "Should not get an error");
    40       for (let s of aResponse.sources) {
    41         do_check_neq(s.url, "http://example.com/www/js/abc.js",
    42                      "Shouldn't get the generated source's url.")
    43         expectedSources.delete(s.url);
    44       }
    46       do_check_eq(expectedSources.size, 0,
    47                   "Should have found all the expected sources sources by now.");
    49       finishClient(gClient);
    50     });
    51   });
    53   let { code, map } = (new SourceNode(null, null, null, [
    54     new SourceNode(1, 0, "a.js", "function a() { return 'a'; }\n"),
    55     new SourceNode(1, 0, "b.js", "function b() { return 'b'; }\n"),
    56     new SourceNode(1, 0, "c.js", "function c() { return 'c'; }\n"),
    57     "debugger;\n"
    58   ])).toStringWithSourceMap({
    59     file: "abc.js",
    60     sourceRoot: "http://example.com/www/js/"
    61   });
    63   code += "//# sourceMappingURL=data:text/json;base64," + btoa(map.toString());
    65   Components.utils.evalInSandbox(code, gDebuggee, "1.8",
    66                                  "http://example.com/www/js/abc.js", 1);
    67 }

mercurial