Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Makes sure the source editor's scroll location doesn't change when |
michael@0 | 6 | * a variable inspection popup is opened and a watch expression is |
michael@0 | 7 | * also evaluated at the same time. |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; |
michael@0 | 11 | |
michael@0 | 12 | function test() { |
michael@0 | 13 | Task.spawn(function() { |
michael@0 | 14 | let [tab, debuggee, panel] = yield initDebugger(TAB_URL); |
michael@0 | 15 | let win = panel.panelWin; |
michael@0 | 16 | let events = win.EVENTS; |
michael@0 | 17 | let editor = win.DebuggerView.editor; |
michael@0 | 18 | let editorContainer = win.document.getElementById("editor"); |
michael@0 | 19 | let bubble = win.DebuggerView.VariableBubble; |
michael@0 | 20 | let expressions = win.DebuggerView.WatchExpressions; |
michael@0 | 21 | let tooltip = bubble._tooltip.panel; |
michael@0 | 22 | |
michael@0 | 23 | // Allow this generator function to yield first. |
michael@0 | 24 | executeSoon(() => debuggee.start()); |
michael@0 | 25 | yield waitForSourceAndCaretAndScopes(panel, ".html", 24); |
michael@0 | 26 | |
michael@0 | 27 | let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
michael@0 | 28 | expressions.addExpression("this"); |
michael@0 | 29 | editor.focus(); |
michael@0 | 30 | yield expressionsEvaluated; |
michael@0 | 31 | |
michael@0 | 32 | // Scroll to the top of the editor and inspect variables. |
michael@0 | 33 | let breakpointScrollPosition = editor.getScrollInfo().top; |
michael@0 | 34 | editor.setFirstVisibleLine(0); |
michael@0 | 35 | let topmostScrollPosition = editor.getScrollInfo().top; |
michael@0 | 36 | |
michael@0 | 37 | ok(topmostScrollPosition < breakpointScrollPosition, |
michael@0 | 38 | "The editor is now scrolled to the top (0)."); |
michael@0 | 39 | is(editor.getFirstVisibleLine(), 0, |
michael@0 | 40 | "The editor is now scrolled to the top (1)."); |
michael@0 | 41 | |
michael@0 | 42 | let failPopup = () => ok(false, "The popup has got unexpectedly hidden."); |
michael@0 | 43 | let failScroll = () => ok(false, "The editor has got unexpectedly scrolled."); |
michael@0 | 44 | tooltip.addEventListener("popuphiding", failPopup); |
michael@0 | 45 | editorContainer.addEventListener("scroll", failScroll); |
michael@0 | 46 | editor.on("scroll", () => { |
michael@0 | 47 | if (editor.getScrollInfo().top > topmostScrollPosition) { |
michael@0 | 48 | ok(false, "The editor scrolled back to the breakpoint location."); |
michael@0 | 49 | } |
michael@0 | 50 | }); |
michael@0 | 51 | |
michael@0 | 52 | let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
michael@0 | 53 | yield openVarPopup(panel, { line: 14, ch: 15 }); |
michael@0 | 54 | yield expressionsEvaluated; |
michael@0 | 55 | |
michael@0 | 56 | tooltip.removeEventListener("popuphiding", failPopup); |
michael@0 | 57 | editorContainer.removeEventListener("scroll", failScroll); |
michael@0 | 58 | |
michael@0 | 59 | yield resumeDebuggerThenCloseAndFinish(panel); |
michael@0 | 60 | }); |
michael@0 | 61 | } |