|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test exceptions inside black boxed sources. |
|
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 // XXX: We have to do an executeSoon so that the error isn't caught and |
|
21 // reported by DebuggerClient.requester (because we are using the local |
|
22 // transport and share a stack) which causes the test to fail. |
|
23 Services.tm.mainThread.dispatch({ |
|
24 run: test_black_box |
|
25 }, Ci.nsIThread.DISPATCH_NORMAL); |
|
26 }); |
|
27 }); |
|
28 do_test_pending(); |
|
29 } |
|
30 |
|
31 const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; |
|
32 const SOURCE_URL = "http://example.com/source.js"; |
|
33 |
|
34 function test_black_box() |
|
35 { |
|
36 gClient.addOneTimeListener("paused", test_black_box_exception); |
|
37 |
|
38 Components.utils.evalInSandbox( |
|
39 "" + function doStuff(k) { // line 1 |
|
40 throw new Error("wu tang clan ain't nuthin' ta fuck wit"); // line 2 |
|
41 k(100); // line 3 |
|
42 }, // line 4 |
|
43 gDebuggee, |
|
44 "1.8", |
|
45 BLACK_BOXED_URL, |
|
46 1 |
|
47 ); |
|
48 |
|
49 Components.utils.evalInSandbox( |
|
50 "" + function runTest() { // line 1 |
|
51 doStuff( // line 2 |
|
52 function (n) { // line 3 |
|
53 debugger; // line 4 |
|
54 } // line 5 |
|
55 ); // line 6 |
|
56 } // line 7 |
|
57 + "\ndebugger;\n" // line 8 |
|
58 + "try { runTest() } catch (ex) { }", // line 9 |
|
59 gDebuggee, |
|
60 "1.8", |
|
61 SOURCE_URL, |
|
62 1 |
|
63 ); |
|
64 } |
|
65 |
|
66 function test_black_box_exception() { |
|
67 gThreadClient.getSources(function ({error, sources}) { |
|
68 do_check_true(!error, "Should not get an error: " + error); |
|
69 let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]); |
|
70 |
|
71 sourceClient.blackBox(function ({error}) { |
|
72 do_check_true(!error, "Should not get an error: " + error); |
|
73 gThreadClient.pauseOnExceptions(true); |
|
74 |
|
75 gClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
|
76 do_check_neq(aPacket.frame.where.url, BLACK_BOXED_URL, |
|
77 "We shouldn't pause while in the black boxed source."); |
|
78 finishClient(gClient); |
|
79 }); |
|
80 |
|
81 gThreadClient.resume(); |
|
82 }); |
|
83 }); |
|
84 } |