browser/devtools/debugger/test/browser_dbg_variables-view-popup-10.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_variables-view-popup-10.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 + * Makes sure the source editor's scroll location doesn't change when
     1.9 + * a variable inspection popup is opened and a watch expression is
    1.10 + * also evaluated at the same time.
    1.11 + */
    1.12 +
    1.13 +const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
    1.14 +
    1.15 +function test() {
    1.16 +  Task.spawn(function() {
    1.17 +    let [tab, debuggee, panel] = yield initDebugger(TAB_URL);
    1.18 +    let win = panel.panelWin;
    1.19 +    let events = win.EVENTS;
    1.20 +    let editor = win.DebuggerView.editor;
    1.21 +    let editorContainer = win.document.getElementById("editor");
    1.22 +    let bubble = win.DebuggerView.VariableBubble;
    1.23 +    let expressions = win.DebuggerView.WatchExpressions;
    1.24 +    let tooltip = bubble._tooltip.panel;
    1.25 +
    1.26 +    // Allow this generator function to yield first.
    1.27 +    executeSoon(() => debuggee.start());
    1.28 +    yield waitForSourceAndCaretAndScopes(panel, ".html", 24);
    1.29 +
    1.30 +    let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
    1.31 +    expressions.addExpression("this");
    1.32 +    editor.focus();
    1.33 +    yield expressionsEvaluated;
    1.34 +
    1.35 +    // Scroll to the top of the editor and inspect variables.
    1.36 +    let breakpointScrollPosition = editor.getScrollInfo().top;
    1.37 +    editor.setFirstVisibleLine(0);
    1.38 +    let topmostScrollPosition = editor.getScrollInfo().top;
    1.39 +
    1.40 +    ok(topmostScrollPosition < breakpointScrollPosition,
    1.41 +      "The editor is now scrolled to the top (0).");
    1.42 +    is(editor.getFirstVisibleLine(), 0,
    1.43 +      "The editor is now scrolled to the top (1).");
    1.44 +
    1.45 +    let failPopup = () => ok(false, "The popup has got unexpectedly hidden.");
    1.46 +    let failScroll = () => ok(false, "The editor has got unexpectedly scrolled.");
    1.47 +    tooltip.addEventListener("popuphiding", failPopup);
    1.48 +    editorContainer.addEventListener("scroll", failScroll);
    1.49 +    editor.on("scroll", () => {
    1.50 +      if (editor.getScrollInfo().top > topmostScrollPosition) {
    1.51 +        ok(false, "The editor scrolled back to the breakpoint location.");
    1.52 +      }
    1.53 +    });
    1.54 +
    1.55 +    let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
    1.56 +    yield openVarPopup(panel, { line: 14, ch: 15 });
    1.57 +    yield expressionsEvaluated;
    1.58 +
    1.59 +    tooltip.removeEventListener("popuphiding", failPopup);
    1.60 +    editorContainer.removeEventListener("scroll", failScroll);
    1.61 +
    1.62 +    yield resumeDebuggerThenCloseAndFinish(panel);
    1.63 +  });
    1.64 +}

mercurial