browser/devtools/debugger/test/browser_dbg_stack-07.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  * Make sure that after selecting a different stack frame, resuming reselects
     6  * the topmost stackframe, loads the right source in the editor pane and
     7  * highlights the proper line.
     8  */
    10 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    12 let gTab, gDebuggee, gPanel, gDebugger;
    13 let gEditor, gSources, gFrames, gClassicFrames, gToolbar;
    15 function test() {
    16   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    17     gTab = aTab;
    18     gDebuggee = aDebuggee;
    19     gPanel = aPanel;
    20     gDebugger = gPanel.panelWin;
    21     gEditor = gDebugger.DebuggerView.editor;
    22     gSources = gDebugger.DebuggerView.Sources;
    23     gFrames = gDebugger.DebuggerView.StackFrames;
    24     gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList;
    25     gToolbar = gDebugger.DebuggerView.Toolbar;
    27     waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest);
    28     gDebuggee.firstCall();
    29   });
    30 }
    32 function performTest() {
    33   return Task.spawn(function() {
    34     yield selectBottomFrame();
    35     testBottomFrame(0);
    37     yield performStep("StepOver");
    38     testTopFrame(3);
    40     yield selectBottomFrame();
    41     testBottomFrame(4);
    43     yield performStep("StepIn");
    44     testTopFrame(2);
    46     yield selectBottomFrame();
    47     testBottomFrame(4);
    49     yield performStep("StepOut");
    50     testTopFrame(2);
    52     yield resumeDebuggerThenCloseAndFinish(gPanel);
    53   });
    55   function selectBottomFrame() {
    56     let updated = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
    57     gClassicFrames.selectedIndex = gClassicFrames.itemCount - 1;
    58     return updated.then(waitForTick);
    59   }
    61   function testBottomFrame(debugLocation) {
    62     is(gFrames.selectedIndex, 0,
    63       "Oldest frame should be selected after click.");
    64     is(gClassicFrames.selectedIndex, gFrames.itemCount - 1,
    65       "Oldest frame should also be selected in the mirrored view.");
    66     is(gSources.selectedIndex, 0,
    67       "The first source is now selected in the widget.");
    68     is(gEditor.getText().search(/firstCall/), 118,
    69       "The first source is displayed.");
    70     is(gEditor.getText().search(/debugger/), -1,
    71       "The second source is not displayed.");
    73     is(gEditor.getDebugLocation(), debugLocation,
    74       "Editor debugger location is correct.");
    75     ok(gEditor.hasLineClass(debugLocation, "debug-line"),
    76       "The debugged line is highlighted appropriately.");
    77   }
    79   function performStep(type) {
    80     let updated = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
    81     gToolbar["_on" + type + "Pressed"]();
    82     return updated.then(waitForTick);
    83   }
    85   function testTopFrame(frameIndex) {
    86     is(gFrames.selectedIndex, frameIndex,
    87       "Topmost frame should be selected after click.");
    88     is(gClassicFrames.selectedIndex, gFrames.itemCount - frameIndex - 1,
    89       "Topmost frame should also be selected in the mirrored view.");
    90     is(gSources.selectedIndex, 1,
    91       "The second source is now selected in the widget.");
    92     is(gEditor.getText().search(/firstCall/), -1,
    93       "The second source is displayed.");
    94     is(gEditor.getText().search(/debugger/), 172,
    95       "The first source is not displayed.");
    96   }
    97 }
    99 registerCleanupFunction(function() {
   100   gTab = null;
   101   gDebuggee = null;
   102   gPanel = null;
   103   gDebugger = null;
   104   gEditor = null;
   105   gSources = null;
   106   gFrames = null;
   107   gClassicFrames = null;
   108   gToolbar = null;
   109 });

mercurial