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