Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Tests that the 'dbg blackbox' and 'dbg unblackbox' commands work as
6 * they should.
7 */
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";
15 function test() {
16 return Task.spawn(spawnTest).then(finish, helpers.handleError);
17 }
19 function spawnTest() {
20 let options = yield helpers.openTab(TEST_URL);
21 yield helpers.openToolbar(options);
23 let toolbox = yield gDevTools.showToolbox(options.target, "jsdebugger");
24 let panel = toolbox.getCurrentPanel();
26 yield waitForDebuggerEvents(panel, panel.panelWin.EVENTS.SOURCE_SHOWN);
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 }
35 // test Black-Box Source
36 yield cmd("dbg blackbox " + BLACKBOXME_URL);
38 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL);
39 ok(bbButton.checked,
40 "Should be able to black box a specific source.");
42 // test Un-Black-Box Source
43 yield cmd("dbg unblackbox " + BLACKBOXME_URL);
45 let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL);
46 ok(!bbButton.checked,
47 "Should be able to stop black boxing a specific source.");
49 // test Black-Box Glob
50 yield cmd("dbg blackbox --glob *blackboxing_t*.js", 2,
51 [/blackboxing_three\.js/g, /blackboxing_two\.js/g]);
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.");
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.");
67 // test Un-Black-Box Glob
68 yield cmd("dbg unblackbox --glob *blackboxing_t*.js", 2);
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.");
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]);
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.");
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.");
98 // test Un-Black-Box Invert
99 yield cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3);
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.");
111 yield teardown(panel, { noTabRemoval: true });
112 yield helpers.closeToolbar(options);
113 yield helpers.closeTab(options);
114 }