browser/devtools/debugger/test/browser_dbg_blackboxing-04.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 * Test that we get a stack frame for each black boxed source, not a single one
michael@0 6 * for all of them.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html";
michael@0 10 const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js"
michael@0 11
michael@0 12 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 13 let gFrames;
michael@0 14
michael@0 15 function test() {
michael@0 16 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 17 gTab = aTab;
michael@0 18 gDebuggee = aDebuggee;
michael@0 19 gPanel = aPanel;
michael@0 20 gDebugger = gPanel.panelWin;
michael@0 21 gFrames = gDebugger.DebuggerView.StackFrames;
michael@0 22
michael@0 23 waitForSourceShown(gPanel, BLACKBOXME_URL)
michael@0 24 .then(blackBoxSources)
michael@0 25 .then(testBlackBoxStack)
michael@0 26 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 27 .then(null, aError => {
michael@0 28 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 29 });
michael@0 30 });
michael@0 31 }
michael@0 32
michael@0 33 function blackBoxSources() {
michael@0 34 let finished = waitForThreadEvents(gPanel, "blackboxchange", 3);
michael@0 35 toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_one.js");
michael@0 36 toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_two.js");
michael@0 37 toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_three.js");
michael@0 38 return finished;
michael@0 39 }
michael@0 40
michael@0 41 function testBlackBoxStack() {
michael@0 42 let finished = waitForSourceAndCaretAndScopes(gPanel, ".html", 21).then(() => {
michael@0 43 is(gFrames.itemCount, 4,
michael@0 44 "Should get 4 frames (one -> two -> three -> doDebuggerStatement).");
michael@0 45 is(gDebugger.document.querySelectorAll(".dbg-stackframe-black-boxed").length, 3,
michael@0 46 "And 'one', 'two', and 'three' should each have their own black boxed frame.");
michael@0 47 });
michael@0 48
michael@0 49 // Spin the event loop before causing the debuggee to pause, to allow
michael@0 50 // this function to return first.
michael@0 51 executeSoon(() => gDebuggee.one());
michael@0 52 return finished;
michael@0 53 }
michael@0 54
michael@0 55 registerCleanupFunction(function() {
michael@0 56 gTab = null;
michael@0 57 gDebuggee = null;
michael@0 58 gPanel = null;
michael@0 59 gDebugger = null;
michael@0 60 gFrames = null;
michael@0 61 });

mercurial