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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     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 + * Test that we get a stack frame for each black boxed source, not a single one
     1.9 + * for all of them.
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html";
    1.13 +const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js"
    1.14 +
    1.15 +let gTab, gDebuggee, gPanel, gDebugger;
    1.16 +let gFrames;
    1.17 +
    1.18 +function test() {
    1.19 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.20 +    gTab = aTab;
    1.21 +    gDebuggee = aDebuggee;
    1.22 +    gPanel = aPanel;
    1.23 +    gDebugger = gPanel.panelWin;
    1.24 +    gFrames = gDebugger.DebuggerView.StackFrames;
    1.25 +
    1.26 +    waitForSourceShown(gPanel, BLACKBOXME_URL)
    1.27 +      .then(blackBoxSources)
    1.28 +      .then(testBlackBoxStack)
    1.29 +      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    1.30 +      .then(null, aError => {
    1.31 +        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.32 +      });
    1.33 +  });
    1.34 +}
    1.35 +
    1.36 +function blackBoxSources() {
    1.37 +  let finished = waitForThreadEvents(gPanel, "blackboxchange", 3);
    1.38 +  toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_one.js");
    1.39 +  toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_two.js");
    1.40 +  toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_three.js");
    1.41 +  return finished;
    1.42 +}
    1.43 +
    1.44 +function testBlackBoxStack() {
    1.45 +  let finished = waitForSourceAndCaretAndScopes(gPanel, ".html", 21).then(() => {
    1.46 +    is(gFrames.itemCount, 4,
    1.47 +      "Should get 4 frames (one -> two -> three -> doDebuggerStatement).");
    1.48 +    is(gDebugger.document.querySelectorAll(".dbg-stackframe-black-boxed").length, 3,
    1.49 +      "And 'one', 'two', and 'three' should each have their own black boxed frame.");
    1.50 +  });
    1.51 +
    1.52 +  // Spin the event loop before causing the debuggee to pause, to allow
    1.53 +  // this function to return first.
    1.54 +  executeSoon(() => gDebuggee.one());
    1.55 +  return finished;
    1.56 +}
    1.57 +
    1.58 +registerCleanupFunction(function() {
    1.59 +  gTab = null;
    1.60 +  gDebuggee = null;
    1.61 +  gPanel = null;
    1.62 +  gDebugger = null;
    1.63 +  gFrames = null;
    1.64 +});

mercurial