michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that the 'dbg blackbox' and 'dbg unblackbox' commands work as michael@0: * they should. michael@0: */ michael@0: michael@0: const TEST_URL = EXAMPLE_URL + "doc_blackboxing.html"; michael@0: const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js"; michael@0: const BLACKBOXONE_URL = EXAMPLE_URL + "code_blackboxing_one.js"; michael@0: const BLACKBOXTWO_URL = EXAMPLE_URL + "code_blackboxing_two.js"; michael@0: const BLACKBOXTHREE_URL = EXAMPLE_URL + "code_blackboxing_three.js"; michael@0: michael@0: function test() { michael@0: return Task.spawn(spawnTest).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: function spawnTest() { michael@0: let options = yield helpers.openTab(TEST_URL); michael@0: yield helpers.openToolbar(options); michael@0: michael@0: let toolbox = yield gDevTools.showToolbox(options.target, "jsdebugger"); michael@0: let panel = toolbox.getCurrentPanel(); michael@0: michael@0: yield waitForDebuggerEvents(panel, panel.panelWin.EVENTS.SOURCE_SHOWN); michael@0: michael@0: function cmd(aTyped, aEventRepeat = 1, aOutput = "") { michael@0: return promise.all([ michael@0: waitForThreadEvents(panel, "blackboxchange", aEventRepeat), michael@0: helpers.audit(options, [{ setup: aTyped, output: aOutput, exec: {} }]) michael@0: ]); michael@0: } michael@0: michael@0: // test Black-Box Source michael@0: yield cmd("dbg blackbox " + BLACKBOXME_URL); michael@0: michael@0: let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); michael@0: ok(bbButton.checked, michael@0: "Should be able to black box a specific source."); michael@0: michael@0: // test Un-Black-Box Source michael@0: yield cmd("dbg unblackbox " + BLACKBOXME_URL); michael@0: michael@0: let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); michael@0: ok(!bbButton.checked, michael@0: "Should be able to stop black boxing a specific source."); michael@0: michael@0: // test Black-Box Glob michael@0: yield cmd("dbg blackbox --glob *blackboxing_t*.js", 2, michael@0: [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); michael@0: michael@0: let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); michael@0: ok(!bbButton.checked, michael@0: "blackboxme should not be black boxed because it doesn't match the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); michael@0: ok(!bbButton.checked, michael@0: "blackbox_one should not be black boxed because it doesn't match the glob."); michael@0: michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); michael@0: ok(bbButton.checked, michael@0: "blackbox_two should be black boxed because it matches the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); michael@0: ok(bbButton.checked, michael@0: "blackbox_three should be black boxed because it matches the glob."); michael@0: michael@0: // test Un-Black-Box Glob michael@0: yield cmd("dbg unblackbox --glob *blackboxing_t*.js", 2); michael@0: michael@0: let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); michael@0: ok(!bbButton.checked, michael@0: "blackbox_two should be un-black boxed because it matches the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); michael@0: ok(!bbButton.checked, michael@0: "blackbox_three should be un-black boxed because it matches the glob."); michael@0: michael@0: // test Black-Box Invert michael@0: yield cmd("dbg blackbox --invert --glob *blackboxing_t*.js", 3, michael@0: [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); michael@0: michael@0: let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); michael@0: ok(bbButton.checked, michael@0: "blackboxme should be black boxed because it doesn't match the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); michael@0: ok(bbButton.checked, michael@0: "blackbox_one should be black boxed because it doesn't match the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, TEST_URL); michael@0: ok(bbButton.checked, michael@0: "TEST_URL should be black boxed because it doesn't match the glob."); michael@0: michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTWO_URL); michael@0: ok(!bbButton.checked, michael@0: "blackbox_two should not be black boxed because it matches the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXTHREE_URL); michael@0: ok(!bbButton.checked, michael@0: "blackbox_three should not be black boxed because it matches the glob."); michael@0: michael@0: // test Un-Black-Box Invert michael@0: yield cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3); michael@0: michael@0: let bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXME_URL); michael@0: ok(!bbButton.checked, michael@0: "blackboxme should be un-black boxed because it does not match the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, BLACKBOXONE_URL); michael@0: ok(!bbButton.checked, michael@0: "blackbox_one should be un-black boxed because it does not match the glob."); michael@0: bbButton = yield selectSourceAndGetBlackBoxButton(panel, TEST_URL); michael@0: ok(!bbButton.checked, michael@0: "TEST_URL should be un-black boxed because it doesn't match the glob."); michael@0: michael@0: yield teardown(panel, { noTabRemoval: true }); michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }