|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test behavior of blackboxing sources we are currently paused in. |
|
6 */ |
|
7 |
|
8 var gDebuggee; |
|
9 var gClient; |
|
10 var gThreadClient; |
|
11 |
|
12 function run_test() |
|
13 { |
|
14 initTestDebuggerServer(); |
|
15 gDebuggee = addTestGlobal("test-black-box"); |
|
16 gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
|
17 gClient.connect(function() { |
|
18 attachTestTabAndResume(gClient, "test-black-box", function(aResponse, aTabClient, aThreadClient) { |
|
19 gThreadClient = aThreadClient; |
|
20 test_black_box(); |
|
21 }); |
|
22 }); |
|
23 do_test_pending(); |
|
24 } |
|
25 |
|
26 const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; |
|
27 const SOURCE_URL = "http://example.com/source.js"; |
|
28 |
|
29 function test_black_box() |
|
30 { |
|
31 gClient.addOneTimeListener("paused", function () { |
|
32 gThreadClient.setBreakpoint({ |
|
33 url: BLACK_BOXED_URL, |
|
34 line: 2 |
|
35 }, function (aResponse) { |
|
36 do_check_true(!aResponse.error, "Should be able to set breakpoint."); |
|
37 test_black_box_paused(); |
|
38 }); |
|
39 }); |
|
40 |
|
41 Components.utils.evalInSandbox( |
|
42 "" + function doStuff(k) { // line 1 |
|
43 debugger; // line 2 |
|
44 k(100); // line 3 |
|
45 }, // line 4 |
|
46 gDebuggee, |
|
47 "1.8", |
|
48 BLACK_BOXED_URL, |
|
49 1 |
|
50 ); |
|
51 |
|
52 Components.utils.evalInSandbox( |
|
53 "" + function runTest() { // line 1 |
|
54 doStuff( // line 2 |
|
55 function (n) { // line 3 |
|
56 return n; // line 4 |
|
57 } // line 5 |
|
58 ); // line 6 |
|
59 } // line 7 |
|
60 + "\n runTest();", // line 8 |
|
61 gDebuggee, |
|
62 "1.8", |
|
63 SOURCE_URL, |
|
64 1 |
|
65 ); |
|
66 } |
|
67 |
|
68 function test_black_box_paused() { |
|
69 gThreadClient.getSources(function ({error, sources}) { |
|
70 do_check_true(!error, "Should not get an error: " + error); |
|
71 let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]); |
|
72 |
|
73 sourceClient.blackBox(function ({error, pausedInSource}) { |
|
74 do_check_true(!error, "Should not get an error: " + error); |
|
75 do_check_true(pausedInSource, "We should be notified that we are currently paused in this source"); |
|
76 finishClient(gClient); |
|
77 }); |
|
78 }); |
|
79 } |