browser/devtools/debugger/test/browser_dbg_stack-02.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Test that stackframes are added when debugger is paused in eval calls.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gFrames, gClassicFrames;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gFrames = gDebugger.DebuggerView.StackFrames;
    20     gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList;
    22     waitForSourceAndCaretAndScopes(gPanel, ".html", 1).then(performTest);
    23     gDebuggee.evalCall();
    24   });
    25 }
    27 function performTest() {
    28   is(gDebugger.gThreadClient.state, "paused",
    29     "Should only be getting stack frames while paused.");
    30   is(gFrames.itemCount, 2,
    31     "Should have two frames.");
    32   is(gClassicFrames.itemCount, 2,
    33     "Should also have only two in the mirrored view.");
    35   is(gFrames.getItemAtIndex(0).attachment.title,
    36     "evalCall", "Oldest frame name should be correct.");
    37   is(gFrames.getItemAtIndex(0).attachment.url,
    38     TAB_URL, "Oldest frame url should be correct.");
    39   is(gClassicFrames.getItemAtIndex(0).attachment.depth,
    40     0, "Oldest frame name is mirrored correctly.");
    42   is(gFrames.getItemAtIndex(1).attachment.title,
    43     "(eval)", "Newest frame name should be correct.");
    44   is(gFrames.getItemAtIndex(1).attachment.url,
    45     TAB_URL, "Newest frame url should be correct.");
    46   is(gClassicFrames.getItemAtIndex(1).attachment.depth,
    47     1, "Newest frame name is mirrored correctly.");
    49   is(gFrames.selectedIndex, 1,
    50     "Newest frame should be selected by default.");
    51   is(gClassicFrames.selectedIndex, 0,
    52     "Newest frame should be selected by default in the mirrored view.");
    54   isnot(gFrames.selectedIndex, 0,
    55     "Oldest frame should not be selected.");
    56   isnot(gClassicFrames.selectedIndex, 1,
    57     "Oldest frame should not be selected in the mirrored view.");
    59   EventUtils.sendMouseEvent({ type: "mousedown" },
    60     gFrames.getItemAtIndex(0).target,
    61     gDebugger);
    63   isnot(gFrames.selectedIndex, 1,
    64     "Newest frame should not be selected after click.");
    65   isnot(gClassicFrames.selectedIndex, 0,
    66     "Newest frame in the mirrored view should not be selected.");
    68   is(gFrames.selectedIndex, 0,
    69     "Oldest frame should be selected after click.");
    70   is(gClassicFrames.selectedIndex, 1,
    71     "Oldest frame in the mirrored view should be selected.");
    73   EventUtils.sendMouseEvent({ type: "mousedown" },
    74     gFrames.getItemAtIndex(1).target.querySelector(".dbg-stackframe-title"),
    75     gDebugger);
    77   is(gFrames.selectedIndex, 1,
    78     "Newest frame should be selected after click inside the newest frame.");
    79   is(gClassicFrames.selectedIndex, 0,
    80     "Newest frame in the mirrored view should be selected.");
    82   isnot(gFrames.selectedIndex, 0,
    83     "Oldest frame should not be selected after click inside the newest frame.");
    84   isnot(gClassicFrames.selectedIndex, 1,
    85     "Oldest frame in the mirrored view should not be selected.");
    87   EventUtils.sendMouseEvent({ type: "mousedown" },
    88     gFrames.getItemAtIndex(0).target.querySelector(".dbg-stackframe-details"),
    89     gDebugger);
    91   isnot(gFrames.selectedIndex, 1,
    92     "Newest frame should not be selected after click inside the oldest frame.");
    93   isnot(gClassicFrames.selectedIndex, 0,
    94     "Newest frame in the mirrored view should not be selected.");
    96   is(gFrames.selectedIndex, 0,
    97     "Oldest frame should be selected after click inside the oldest frame.");
    98   is(gClassicFrames.selectedIndex, 1,
    99     "Oldest frame in the mirrored view should be selected.");
   101   resumeDebuggerThenCloseAndFinish(gPanel);
   102 }
   104 registerCleanupFunction(function() {
   105   gTab = null;
   106   gDebuggee = null;
   107   gPanel = null;
   108   gDebugger = null;
   109   gFrames = null;
   110   gClassicFrames = null;
   111 });

mercurial