toolkit/devtools/server/tests/unit/test_sourcemaps-08.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Regression test for bug 882986 regarding sourcesContent and absolute source
     6  * URLs.
     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_maps();
    24     });
    25   });
    26   do_test_pending();
    27 }
    29 function test_source_maps()
    30 {
    31   gClient.addOneTimeListener("newSource", function (aEvent, aPacket) {
    32     let sourceClient = gThreadClient.source(aPacket.source);
    33     sourceClient.source(function ({error, source}) {
    34       do_check_true(!error, "should be able to grab the source");
    35       do_check_eq(source, "foo",
    36                   "Should load the source from the sourcesContent field");
    37       finishClient(gClient);
    38     });
    39   });
    41   let code = "'nothing here';\n";
    42   code += "//# sourceMappingURL=data:text/json," + JSON.stringify({
    43     version: 3,
    44     file: "foo.js",
    45     sources: ["/a"],
    46     names: [],
    47     mappings: "AACA",
    48     sourcesContent: ["foo"]
    49   });
    50   Components.utils.evalInSandbox(code, gDebuggee, "1.8",
    51                                  "http://example.com/foo.js", 1);
    52 }

mercurial