1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests that the 'dbg blackbox' and 'dbg unblackbox' commands work as 1.9 + * they should. 1.10 + */ 1.11 + 1.12 +const TEST_URL = EXAMPLE_URL + "doc_blackboxing.html"; 1.13 +const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js"; 1.14 +const BLACKBOXONE_URL = EXAMPLE_URL + "code_blackboxing_one.js"; 1.15 +const BLACKBOXTWO_URL = EXAMPLE_URL + "code_blackboxing_two.js"; 1.16 +const BLACKBOXTHREE_URL = EXAMPLE_URL + "code_blackboxing_three.js"; 1.17 + 1.18 +function test() { 1.19 + return Task.spawn(spawnTest).then(finish, helpers.handleError); 1.20 +} 1.21 + 1.22 +function spawnTest() { 1.23 + let options = yield helpers.openTab(TEST_URL); 1.24 + yield helpers.openToolbar(options); 1.25 + 1.26 + let toolbox = yield gDevTools.showToolbox(options.target, "jsdebugger"); 1.27 + let panel = toolbox.getCurrentPanel(); 1.28 + 1.29 + yield waitForDebuggerEvents(panel, panel.panelWin.EVENTS.SOURCE_SHOWN); 1.30 + 1.31 + function cmd(aTyped, aEventRepeat = 1, aOutput = "") { 1.32 + return promise.all([ 1.33 + waitForThreadEvents(panel, "blackboxchange", aEventRepeat), 1.34 + helpers.audit(options, [{ setup: aTyped, output: aOutput, exec: {} }]) 1.35 + ]); 1.36 + } 1.37 + 1.38 + // test Black-Box Source 1.39 + yield cmd("dbg blackbox " + BLACKBOXME_URL); 1.40 + 1.41 + let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); 1.42 + ok(bbButton.checked, 1.43 + "Should be able to black box a specific source."); 1.44 + 1.45 + // test Un-Black-Box Source 1.46 + yield cmd("dbg unblackbox " + BLACKBOXME_URL); 1.47 + 1.48 + let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); 1.49 + ok(!bbButton.checked, 1.50 + "Should be able to stop black boxing a specific source."); 1.51 + 1.52 + // test Black-Box Glob 1.53 + yield cmd("dbg blackbox --glob *blackboxing_t*.js", 2, 1.54 + [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); 1.55 + 1.56 + let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); 1.57 + ok(!bbButton.checked, 1.58 + "blackboxme should not be black boxed because it doesn't match the glob."); 1.59 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); 1.60 + ok(!bbButton.checked, 1.61 + "blackbox_one should not be black boxed because it doesn't match the glob."); 1.62 + 1.63 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); 1.64 + ok(bbButton.checked, 1.65 + "blackbox_two should be black boxed because it matches the glob."); 1.66 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); 1.67 + ok(bbButton.checked, 1.68 + "blackbox_three should be black boxed because it matches the glob."); 1.69 + 1.70 + // test Un-Black-Box Glob 1.71 + yield cmd("dbg unblackbox --glob *blackboxing_t*.js", 2); 1.72 + 1.73 + let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); 1.74 + ok(!bbButton.checked, 1.75 + "blackbox_two should be un-black boxed because it matches the glob."); 1.76 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); 1.77 + ok(!bbButton.checked, 1.78 + "blackbox_three should be un-black boxed because it matches the glob."); 1.79 + 1.80 + // test Black-Box Invert 1.81 + yield cmd("dbg blackbox --invert --glob *blackboxing_t*.js", 3, 1.82 + [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); 1.83 + 1.84 + let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); 1.85 + ok(bbButton.checked, 1.86 + "blackboxme should be black boxed because it doesn't match the glob."); 1.87 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); 1.88 + ok(bbButton.checked, 1.89 + "blackbox_one should be black boxed because it doesn't match the glob."); 1.90 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, TEST_URL); 1.91 + ok(bbButton.checked, 1.92 + "TEST_URL should be black boxed because it doesn't match the glob."); 1.93 + 1.94 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); 1.95 + ok(!bbButton.checked, 1.96 + "blackbox_two should not be black boxed because it matches the glob."); 1.97 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); 1.98 + ok(!bbButton.checked, 1.99 + "blackbox_three should not be black boxed because it matches the glob."); 1.100 + 1.101 + // test Un-Black-Box Invert 1.102 + yield cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3); 1.103 + 1.104 + let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); 1.105 + ok(!bbButton.checked, 1.106 + "blackboxme should be un-black boxed because it does not match the glob."); 1.107 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); 1.108 + ok(!bbButton.checked, 1.109 + "blackbox_one should be un-black boxed because it does not match the glob."); 1.110 + bbButton = yield selectSourceAndGetBlackBoxButton(panel, TEST_URL); 1.111 + ok(!bbButton.checked, 1.112 + "TEST_URL should be un-black boxed because it doesn't match the glob."); 1.113 + 1.114 + yield teardown(panel, { noTabRemoval: true }); 1.115 + yield helpers.closeToolbar(options); 1.116 + yield helpers.closeTab(options); 1.117 +}