browser/devtools/debugger/test/browser_dbg_controller-evaluate-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  * Tests the public evaluation API from the debugger controller.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    10 function test() {
    11   Task.spawn(function() {
    12     let [tab, debuggee, panel] = yield initDebugger(TAB_URL);
    13     let win = panel.panelWin;
    14     let frames = win.DebuggerController.StackFrames;
    15     let framesView = win.DebuggerView.StackFrames;
    16     let sources = win.DebuggerController.SourceScripts;
    17     let sourcesView = win.DebuggerView.Sources;
    18     let editorView = win.DebuggerView.editor;
    19     let events = win.EVENTS;
    21     function checkView(selectedFrame, selectedSource, caretLine, editorText) {
    22       is(win.gThreadClient.state, "paused",
    23         "Should only be getting stack frames while paused.");
    24       is(framesView.itemCount, 4,
    25         "Should have four frames.");
    26       is(framesView.selectedDepth, selectedFrame,
    27         "The correct frame is selected in the widget.");
    28       is(sourcesView.selectedIndex, selectedSource,
    29         "The correct source is selected in the widget.");
    30       ok(isCaretPos(panel, caretLine),
    31         "Editor caret location is correct.");
    32       is(editorView.getText().search(editorText[0]), editorText[1],
    33         "The correct source is not displayed.");
    34     }
    36     // Cache the sources text to avoid having to wait for their retrieval.
    37     yield promise.all(sourcesView.attachments.map(e => sources.getText(e.source)));
    38     is(sources._cache.size, 2, "There should be two cached sources in the cache.");
    40     // Allow this generator function to yield first.
    41     executeSoon(() => debuggee.firstCall());
    42     yield waitForSourceAndCaretAndScopes(panel, "-02.js", 1);
    43     checkView(0, 1, 1, [/secondCall/, 118]);
    45     // Change the selected frame and eval inside it.
    46     let updatedFrame = waitForDebuggerEvents(panel, events.FETCHED_SCOPES);
    47     framesView.selectedDepth = 3; // oldest frame
    48     yield updatedFrame;
    49     checkView(3, 0, 5, [/firstCall/, 118]);
    51     let updatedView = waitForDebuggerEvents(panel, events.FETCHED_SCOPES);
    52     try {
    53       yield frames.evaluate("foo");
    54     } catch (result) {
    55       is(result.return.type, "object", "The evaluation thrown type is correct.");
    56       is(result.return.class, "Error", "The evaluation thrown class is correct.");
    57       ok(!result.return, "The evaluation hasn't returned.");
    58     }
    60     yield updatedView;
    61     checkView(3, 0, 5, [/firstCall/, 118]);
    62     ok(true, "Evaluating while in a user-selected frame works properly.");
    64     yield resumeDebuggerThenCloseAndFinish(panel);
    65   });
    66 }

mercurial