|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check that relative source map urls work. |
|
6 */ |
|
7 |
|
8 var gDebuggee; |
|
9 var gClient; |
|
10 var gThreadClient; |
|
11 |
|
12 Components.utils.import('resource:///modules/devtools/SourceMap.jsm'); |
|
13 |
|
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); |
|
22 |
|
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 } |
|
36 |
|
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); |
|
43 |
|
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."); |
|
48 |
|
49 finishClient(gClient); |
|
50 }); |
|
51 |
|
52 code = readFile("sourcemapped.js") |
|
53 + "\n//# sourceMappingURL=source-map-data/sourcemapped.map"; |
|
54 |
|
55 Components.utils.evalInSandbox(code, gDebuggee, "1.8", |
|
56 getFileUrl("sourcemapped.js"), 1); |
|
57 } |