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