browser/devtools/debugger/test/browser_dbg_breadcrumbs-access.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:87e18cc0e95d
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests if the stackframe breadcrumbs are keyboard accessible.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
9
10 function test() {
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gSources, gFrames;
13
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;
21
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 });
30
31 gDebuggee.firstCall();
32 });
33
34 function checkNavigationWhileNotFocused() {
35 checkState({ frame: 3, source: 1, line: 1 });
36
37 EventUtils.sendKey("DOWN", gDebugger);
38 checkState({ frame: 3, source: 1, line: 2 });
39
40 EventUtils.sendKey("UP", gDebugger);
41 checkState({ frame: 3, source: 1, line: 1 });
42 }
43
44 function focusCurrentStackFrame() {
45 EventUtils.sendMouseEvent({ type: "mousedown" },
46 gFrames.selectedItem.target,
47 gDebugger);
48 }
49
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 });
57
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 });
64
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 });
70
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 });
77
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 }
86
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 }

mercurial