toolkit/devtools/server/tests/unit/test_sourcemaps-05.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  * Check that relative source map urls work.
     6  */
     8 var gDebuggee;
     9 var gClient;
    10 var gThreadClient;
    12 Components.utils.import('resource:///modules/devtools/SourceMap.jsm');
    14 // Deep in the complicated labyrinth of code that this test invokes, beneath
    15 // debugger callbacks, sandboxes and nested event loops, lies an exception.
    16 // This exception lay sleeping since the dawn of time, held captive in a
    17 // delicate balance of custom xpcshell error reporters and garbage data about
    18 // the XPCCallContext stack. But bholley dug too greedily, and too deep, and
    19 // awoke shadow and flame in the darkness of nsExternalHelperAppService.cpp.
    20 // We must now trust in deep magic to ensure that it does not awaken again.
    21 ignoreReportedErrors(true);
    23 function run_test()
    24 {
    25   initTestDebuggerServer();
    26   gDebuggee = addTestGlobal("test-source-map");
    27   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    28   gClient.connect(function() {
    29     attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) {
    30       gThreadClient = aThreadClient;
    31       test_relative_source_map();
    32     });
    33   });
    34   do_test_pending();
    35 }
    37 function test_relative_source_map()
    38 {
    39   gClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) {
    40     do_check_eq(aEvent, "newSource");
    41     do_check_eq(aPacket.type, "newSource");
    42     do_check_true(!!aPacket.source);
    44     do_check_true(aPacket.source.url.indexOf("sourcemapped.coffee") !== -1,
    45                   "The new source should be a coffee file.");
    46     do_check_eq(aPacket.source.url.indexOf("sourcemapped.js"), -1,
    47                 "The new source should not be a js file.");
    49     finishClient(gClient);
    50   });
    52   code = readFile("sourcemapped.js")
    53     + "\n//# sourceMappingURL=source-map-data/sourcemapped.map";
    55   Components.utils.evalInSandbox(code, gDebuggee, "1.8",
    56                                  getFileUrl("sourcemapped.js"), 1);
    57 }

mercurial