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: * Test that we get a stack frame for each black boxed source, not a single one michael@0: * for all of them. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html"; michael@0: const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js" michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gFrames; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gFrames = gDebugger.DebuggerView.StackFrames; michael@0: michael@0: waitForSourceShown(gPanel, BLACKBOXME_URL) michael@0: .then(blackBoxSources) michael@0: .then(testBlackBoxStack) michael@0: .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function blackBoxSources() { michael@0: let finished = waitForThreadEvents(gPanel, "blackboxchange", 3); michael@0: toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_one.js"); michael@0: toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_two.js"); michael@0: toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_three.js"); michael@0: return finished; michael@0: } michael@0: michael@0: function testBlackBoxStack() { michael@0: let finished = waitForSourceAndCaretAndScopes(gPanel, ".html", 21).then(() => { michael@0: is(gFrames.itemCount, 4, michael@0: "Should get 4 frames (one -> two -> three -> doDebuggerStatement)."); michael@0: is(gDebugger.document.querySelectorAll(".dbg-stackframe-black-boxed").length, 3, michael@0: "And 'one', 'two', and 'three' should each have their own black boxed frame."); michael@0: }); michael@0: michael@0: // Spin the event loop before causing the debuggee to pause, to allow michael@0: // this function to return first. michael@0: executeSoon(() => gDebuggee.one()); michael@0: return finished; michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gFrames = null; michael@0: });