michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Makes sure the source editor's scroll location doesn't change when michael@0: * a variable inspection popup is opened and a watch expression is michael@0: * also evaluated at the same time. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; michael@0: michael@0: function test() { michael@0: Task.spawn(function() { michael@0: let [tab, debuggee, panel] = yield initDebugger(TAB_URL); michael@0: let win = panel.panelWin; michael@0: let events = win.EVENTS; michael@0: let editor = win.DebuggerView.editor; michael@0: let editorContainer = win.document.getElementById("editor"); michael@0: let bubble = win.DebuggerView.VariableBubble; michael@0: let expressions = win.DebuggerView.WatchExpressions; michael@0: let tooltip = bubble._tooltip.panel; michael@0: michael@0: // Allow this generator function to yield first. michael@0: executeSoon(() => debuggee.start()); michael@0: yield waitForSourceAndCaretAndScopes(panel, ".html", 24); michael@0: michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: expressions.addExpression("this"); michael@0: editor.focus(); michael@0: yield expressionsEvaluated; michael@0: michael@0: // Scroll to the top of the editor and inspect variables. michael@0: let breakpointScrollPosition = editor.getScrollInfo().top; michael@0: editor.setFirstVisibleLine(0); michael@0: let topmostScrollPosition = editor.getScrollInfo().top; michael@0: michael@0: ok(topmostScrollPosition < breakpointScrollPosition, michael@0: "The editor is now scrolled to the top (0)."); michael@0: is(editor.getFirstVisibleLine(), 0, michael@0: "The editor is now scrolled to the top (1)."); michael@0: michael@0: let failPopup = () => ok(false, "The popup has got unexpectedly hidden."); michael@0: let failScroll = () => ok(false, "The editor has got unexpectedly scrolled."); michael@0: tooltip.addEventListener("popuphiding", failPopup); michael@0: editorContainer.addEventListener("scroll", failScroll); michael@0: editor.on("scroll", () => { michael@0: if (editor.getScrollInfo().top > topmostScrollPosition) { michael@0: ok(false, "The editor scrolled back to the breakpoint location."); michael@0: } michael@0: }); michael@0: michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: yield openVarPopup(panel, { line: 14, ch: 15 }); michael@0: yield expressionsEvaluated; michael@0: michael@0: tooltip.removeEventListener("popuphiding", failPopup); michael@0: editorContainer.removeEventListener("scroll", failScroll); michael@0: michael@0: yield resumeDebuggerThenCloseAndFinish(panel); michael@0: }); michael@0: }