browser/devtools/debugger/test/browser_dbg_stack-02.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_stack-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,111 @@
     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 stackframes are added when debugger is paused in eval calls.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
    1.12 +
    1.13 +let gTab, gDebuggee, gPanel, gDebugger;
    1.14 +let gFrames, gClassicFrames;
    1.15 +
    1.16 +function test() {
    1.17 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.18 +    gTab = aTab;
    1.19 +    gDebuggee = aDebuggee;
    1.20 +    gPanel = aPanel;
    1.21 +    gDebugger = gPanel.panelWin;
    1.22 +    gFrames = gDebugger.DebuggerView.StackFrames;
    1.23 +    gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList;
    1.24 +
    1.25 +    waitForSourceAndCaretAndScopes(gPanel, ".html", 1).then(performTest);
    1.26 +    gDebuggee.evalCall();
    1.27 +  });
    1.28 +}
    1.29 +
    1.30 +function performTest() {
    1.31 +  is(gDebugger.gThreadClient.state, "paused",
    1.32 +    "Should only be getting stack frames while paused.");
    1.33 +  is(gFrames.itemCount, 2,
    1.34 +    "Should have two frames.");
    1.35 +  is(gClassicFrames.itemCount, 2,
    1.36 +    "Should also have only two in the mirrored view.");
    1.37 +
    1.38 +  is(gFrames.getItemAtIndex(0).attachment.title,
    1.39 +    "evalCall", "Oldest frame name should be correct.");
    1.40 +  is(gFrames.getItemAtIndex(0).attachment.url,
    1.41 +    TAB_URL, "Oldest frame url should be correct.");
    1.42 +  is(gClassicFrames.getItemAtIndex(0).attachment.depth,
    1.43 +    0, "Oldest frame name is mirrored correctly.");
    1.44 +
    1.45 +  is(gFrames.getItemAtIndex(1).attachment.title,
    1.46 +    "(eval)", "Newest frame name should be correct.");
    1.47 +  is(gFrames.getItemAtIndex(1).attachment.url,
    1.48 +    TAB_URL, "Newest frame url should be correct.");
    1.49 +  is(gClassicFrames.getItemAtIndex(1).attachment.depth,
    1.50 +    1, "Newest frame name is mirrored correctly.");
    1.51 +
    1.52 +  is(gFrames.selectedIndex, 1,
    1.53 +    "Newest frame should be selected by default.");
    1.54 +  is(gClassicFrames.selectedIndex, 0,
    1.55 +    "Newest frame should be selected by default in the mirrored view.");
    1.56 +
    1.57 +  isnot(gFrames.selectedIndex, 0,
    1.58 +    "Oldest frame should not be selected.");
    1.59 +  isnot(gClassicFrames.selectedIndex, 1,
    1.60 +    "Oldest frame should not be selected in the mirrored view.");
    1.61 +
    1.62 +  EventUtils.sendMouseEvent({ type: "mousedown" },
    1.63 +    gFrames.getItemAtIndex(0).target,
    1.64 +    gDebugger);
    1.65 +
    1.66 +  isnot(gFrames.selectedIndex, 1,
    1.67 +    "Newest frame should not be selected after click.");
    1.68 +  isnot(gClassicFrames.selectedIndex, 0,
    1.69 +    "Newest frame in the mirrored view should not be selected.");
    1.70 +
    1.71 +  is(gFrames.selectedIndex, 0,
    1.72 +    "Oldest frame should be selected after click.");
    1.73 +  is(gClassicFrames.selectedIndex, 1,
    1.74 +    "Oldest frame in the mirrored view should be selected.");
    1.75 +
    1.76 +  EventUtils.sendMouseEvent({ type: "mousedown" },
    1.77 +    gFrames.getItemAtIndex(1).target.querySelector(".dbg-stackframe-title"),
    1.78 +    gDebugger);
    1.79 +
    1.80 +  is(gFrames.selectedIndex, 1,
    1.81 +    "Newest frame should be selected after click inside the newest frame.");
    1.82 +  is(gClassicFrames.selectedIndex, 0,
    1.83 +    "Newest frame in the mirrored view should be selected.");
    1.84 +
    1.85 +  isnot(gFrames.selectedIndex, 0,
    1.86 +    "Oldest frame should not be selected after click inside the newest frame.");
    1.87 +  isnot(gClassicFrames.selectedIndex, 1,
    1.88 +    "Oldest frame in the mirrored view should not be selected.");
    1.89 +
    1.90 +  EventUtils.sendMouseEvent({ type: "mousedown" },
    1.91 +    gFrames.getItemAtIndex(0).target.querySelector(".dbg-stackframe-details"),
    1.92 +    gDebugger);
    1.93 +
    1.94 +  isnot(gFrames.selectedIndex, 1,
    1.95 +    "Newest frame should not be selected after click inside the oldest frame.");
    1.96 +  isnot(gClassicFrames.selectedIndex, 0,
    1.97 +    "Newest frame in the mirrored view should not be selected.");
    1.98 +
    1.99 +  is(gFrames.selectedIndex, 0,
   1.100 +    "Oldest frame should be selected after click inside the oldest frame.");
   1.101 +  is(gClassicFrames.selectedIndex, 1,
   1.102 +    "Oldest frame in the mirrored view should be selected.");
   1.103 +
   1.104 +  resumeDebuggerThenCloseAndFinish(gPanel);
   1.105 +}
   1.106 +
   1.107 +registerCleanupFunction(function() {
   1.108 +  gTab = null;
   1.109 +  gDebuggee = null;
   1.110 +  gPanel = null;
   1.111 +  gDebugger = null;
   1.112 +  gFrames = null;
   1.113 +  gClassicFrames = null;
   1.114 +});

mercurial