|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Regression test for bug 882986 regarding sourcesContent and absolute source |
|
6 * URLs. |
|
7 */ |
|
8 |
|
9 var gDebuggee; |
|
10 var gClient; |
|
11 var gThreadClient; |
|
12 |
|
13 Components.utils.import("resource:///modules/devtools/SourceMap.jsm"); |
|
14 |
|
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 } |
|
28 |
|
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 }); |
|
40 |
|
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 } |