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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 * Tests if the stackframe breadcrumbs are keyboard accessible.
michael@0 6 */
michael@0 7
michael@0 8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
michael@0 9
michael@0 10 function test() {
michael@0 11 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 12 let gSources, gFrames;
michael@0 13
michael@0 14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 15 gTab = aTab;
michael@0 16 gDebuggee = aDebuggee;
michael@0 17 gPanel = aPanel;
michael@0 18 gDebugger = gPanel.panelWin;
michael@0 19 gSources = gDebugger.DebuggerView.Sources;
michael@0 20 gFrames = gDebugger.DebuggerView.StackFrames;
michael@0 21
michael@0 22 waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
michael@0 23 .then(checkNavigationWhileNotFocused)
michael@0 24 .then(focusCurrentStackFrame)
michael@0 25 .then(checkNavigationWhileFocused)
michael@0 26 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 27 .then(null, aError => {
michael@0 28 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 29 });
michael@0 30
michael@0 31 gDebuggee.firstCall();
michael@0 32 });
michael@0 33
michael@0 34 function checkNavigationWhileNotFocused() {
michael@0 35 checkState({ frame: 3, source: 1, line: 1 });
michael@0 36
michael@0 37 EventUtils.sendKey("DOWN", gDebugger);
michael@0 38 checkState({ frame: 3, source: 1, line: 2 });
michael@0 39
michael@0 40 EventUtils.sendKey("UP", gDebugger);
michael@0 41 checkState({ frame: 3, source: 1, line: 1 });
michael@0 42 }
michael@0 43
michael@0 44 function focusCurrentStackFrame() {
michael@0 45 EventUtils.sendMouseEvent({ type: "mousedown" },
michael@0 46 gFrames.selectedItem.target,
michael@0 47 gDebugger);
michael@0 48 }
michael@0 49
michael@0 50 function checkNavigationWhileFocused() {
michael@0 51 return Task.spawn(function() {
michael@0 52 yield promise.all([
michael@0 53 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
michael@0 54 EventUtils.sendKey("UP", gDebugger)
michael@0 55 ]);
michael@0 56 checkState({ frame: 2, source: 1, line: 1 });
michael@0 57
michael@0 58 yield promise.all([
michael@0 59 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
michael@0 60 waitForSourceAndCaret(gPanel, "-01.js", 1),
michael@0 61 EventUtils.sendKey("UP", gDebugger)
michael@0 62 ]);
michael@0 63 checkState({ frame: 1, source: 0, line: 1 });
michael@0 64
michael@0 65 yield promise.all([
michael@0 66 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
michael@0 67 EventUtils.sendKey("UP", gDebugger)
michael@0 68 ]);
michael@0 69 checkState({ frame: 0, source: 0, line: 5 });
michael@0 70
michael@0 71 yield promise.all([
michael@0 72 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
michael@0 73 waitForSourceAndCaret(gPanel, "-02.js", 1),
michael@0 74 EventUtils.sendKey("END", gDebugger)
michael@0 75 ]);
michael@0 76 checkState({ frame: 3, source: 1, line: 1 });
michael@0 77
michael@0 78 yield promise.all([
michael@0 79 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
michael@0 80 waitForSourceAndCaret(gPanel, "-01.js", 1),
michael@0 81 EventUtils.sendKey("HOME", gDebugger)
michael@0 82 ]);
michael@0 83 checkState({ frame: 0, source: 0, line: 5 });
michael@0 84 });
michael@0 85 }
michael@0 86
michael@0 87 function checkState({ frame, source, line }) {
michael@0 88 is(gFrames.selectedIndex, frame,
michael@0 89 "The currently selected stackframe is incorrect.");
michael@0 90 is(gSources.selectedIndex, source,
michael@0 91 "The currently selected source is incorrect.");
michael@0 92 ok(isCaretPos(gPanel, line),
michael@0 93 "The source editor caret position was incorrect.");
michael@0 94 }
michael@0 95 }

mercurial