|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that the 'dbg blackbox' and 'dbg unblackbox' commands work as |
|
6 * they should. |
|
7 */ |
|
8 |
|
9 const TEST_URL = EXAMPLE_URL + "doc_blackboxing.html"; |
|
10 const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js"; |
|
11 const BLACKBOXONE_URL = EXAMPLE_URL + "code_blackboxing_one.js"; |
|
12 const BLACKBOXTWO_URL = EXAMPLE_URL + "code_blackboxing_two.js"; |
|
13 const BLACKBOXTHREE_URL = EXAMPLE_URL + "code_blackboxing_three.js"; |
|
14 |
|
15 function test() { |
|
16 return Task.spawn(spawnTest).then(finish, helpers.handleError); |
|
17 } |
|
18 |
|
19 function spawnTest() { |
|
20 let options = yield helpers.openTab(TEST_URL); |
|
21 yield helpers.openToolbar(options); |
|
22 |
|
23 let toolbox = yield gDevTools.showToolbox(options.target, "jsdebugger"); |
|
24 let panel = toolbox.getCurrentPanel(); |
|
25 |
|
26 yield waitForDebuggerEvents(panel, panel.panelWin.EVENTS.SOURCE_SHOWN); |
|
27 |
|
28 function cmd(aTyped, aEventRepeat = 1, aOutput = "") { |
|
29 return promise.all([ |
|
30 waitForThreadEvents(panel, "blackboxchange", aEventRepeat), |
|
31 helpers.audit(options, [{ setup: aTyped, output: aOutput, exec: {} }]) |
|
32 ]); |
|
33 } |
|
34 |
|
35 // test Black-Box Source |
|
36 yield cmd("dbg blackbox " + BLACKBOXME_URL); |
|
37 |
|
38 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); |
|
39 ok(bbButton.checked, |
|
40 "Should be able to black box a specific source."); |
|
41 |
|
42 // test Un-Black-Box Source |
|
43 yield cmd("dbg unblackbox " + BLACKBOXME_URL); |
|
44 |
|
45 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); |
|
46 ok(!bbButton.checked, |
|
47 "Should be able to stop black boxing a specific source."); |
|
48 |
|
49 // test Black-Box Glob |
|
50 yield cmd("dbg blackbox --glob *blackboxing_t*.js", 2, |
|
51 [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); |
|
52 |
|
53 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); |
|
54 ok(!bbButton.checked, |
|
55 "blackboxme should not be black boxed because it doesn't match the glob."); |
|
56 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); |
|
57 ok(!bbButton.checked, |
|
58 "blackbox_one should not be black boxed because it doesn't match the glob."); |
|
59 |
|
60 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); |
|
61 ok(bbButton.checked, |
|
62 "blackbox_two should be black boxed because it matches the glob."); |
|
63 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); |
|
64 ok(bbButton.checked, |
|
65 "blackbox_three should be black boxed because it matches the glob."); |
|
66 |
|
67 // test Un-Black-Box Glob |
|
68 yield cmd("dbg unblackbox --glob *blackboxing_t*.js", 2); |
|
69 |
|
70 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); |
|
71 ok(!bbButton.checked, |
|
72 "blackbox_two should be un-black boxed because it matches the glob."); |
|
73 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); |
|
74 ok(!bbButton.checked, |
|
75 "blackbox_three should be un-black boxed because it matches the glob."); |
|
76 |
|
77 // test Black-Box Invert |
|
78 yield cmd("dbg blackbox --invert --glob *blackboxing_t*.js", 3, |
|
79 [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); |
|
80 |
|
81 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); |
|
82 ok(bbButton.checked, |
|
83 "blackboxme should be black boxed because it doesn't match the glob."); |
|
84 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); |
|
85 ok(bbButton.checked, |
|
86 "blackbox_one should be black boxed because it doesn't match the glob."); |
|
87 bbButton = yield selectSourceAndGetBlackBoxButton(panel, TEST_URL); |
|
88 ok(bbButton.checked, |
|
89 "TEST_URL should be black boxed because it doesn't match the glob."); |
|
90 |
|
91 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); |
|
92 ok(!bbButton.checked, |
|
93 "blackbox_two should not be black boxed because it matches the glob."); |
|
94 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); |
|
95 ok(!bbButton.checked, |
|
96 "blackbox_three should not be black boxed because it matches the glob."); |
|
97 |
|
98 // test Un-Black-Box Invert |
|
99 yield cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3); |
|
100 |
|
101 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); |
|
102 ok(!bbButton.checked, |
|
103 "blackboxme should be un-black boxed because it does not match the glob."); |
|
104 bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); |
|
105 ok(!bbButton.checked, |
|
106 "blackbox_one should be un-black boxed because it does not match the glob."); |
|
107 bbButton = yield selectSourceAndGetBlackBoxButton(panel, TEST_URL); |
|
108 ok(!bbButton.checked, |
|
109 "TEST_URL should be un-black boxed because it doesn't match the glob."); |
|
110 |
|
111 yield teardown(panel, { noTabRemoval: true }); |
|
112 yield helpers.closeToolbar(options); |
|
113 yield helpers.closeTab(options); |
|
114 } |