Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Tests if the stackframe breadcrumbs are keyboard accessible.
6 */
8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
10 function test() {
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gSources, gFrames;
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
15 gTab = aTab;
16 gDebuggee = aDebuggee;
17 gPanel = aPanel;
18 gDebugger = gPanel.panelWin;
19 gSources = gDebugger.DebuggerView.Sources;
20 gFrames = gDebugger.DebuggerView.StackFrames;
22 waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
23 .then(checkNavigationWhileNotFocused)
24 .then(focusCurrentStackFrame)
25 .then(checkNavigationWhileFocused)
26 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
27 .then(null, aError => {
28 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
29 });
31 gDebuggee.firstCall();
32 });
34 function checkNavigationWhileNotFocused() {
35 checkState({ frame: 3, source: 1, line: 1 });
37 EventUtils.sendKey("DOWN", gDebugger);
38 checkState({ frame: 3, source: 1, line: 2 });
40 EventUtils.sendKey("UP", gDebugger);
41 checkState({ frame: 3, source: 1, line: 1 });
42 }
44 function focusCurrentStackFrame() {
45 EventUtils.sendMouseEvent({ type: "mousedown" },
46 gFrames.selectedItem.target,
47 gDebugger);
48 }
50 function checkNavigationWhileFocused() {
51 return Task.spawn(function() {
52 yield promise.all([
53 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
54 EventUtils.sendKey("UP", gDebugger)
55 ]);
56 checkState({ frame: 2, source: 1, line: 1 });
58 yield promise.all([
59 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
60 waitForSourceAndCaret(gPanel, "-01.js", 1),
61 EventUtils.sendKey("UP", gDebugger)
62 ]);
63 checkState({ frame: 1, source: 0, line: 1 });
65 yield promise.all([
66 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
67 EventUtils.sendKey("UP", gDebugger)
68 ]);
69 checkState({ frame: 0, source: 0, line: 5 });
71 yield promise.all([
72 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
73 waitForSourceAndCaret(gPanel, "-02.js", 1),
74 EventUtils.sendKey("END", gDebugger)
75 ]);
76 checkState({ frame: 3, source: 1, line: 1 });
78 yield promise.all([
79 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
80 waitForSourceAndCaret(gPanel, "-01.js", 1),
81 EventUtils.sendKey("HOME", gDebugger)
82 ]);
83 checkState({ frame: 0, source: 0, line: 5 });
84 });
85 }
87 function checkState({ frame, source, line }) {
88 is(gFrames.selectedIndex, frame,
89 "The currently selected stackframe is incorrect.");
90 is(gSources.selectedIndex, source,
91 "The currently selected source is incorrect.");
92 ok(isCaretPos(gPanel, line),
93 "The source editor caret position was incorrect.");
94 }
95 }