1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Check that basic keyboard shortcuts work in the web console.
"use strict";
const TEST_URI =
`data:text/html;charset=utf-8,<p>Test keyboard accessibility</p>
<script>
for (let i = 1; i <= 100; i++) {
console.log("console message " + i);
}
</script>
`;
add_task(function* () {
let hud = yield openNewTabAndConsole(TEST_URI);
info("Web Console opened");
const outputScroller = hud.ui.outputScroller;
yield waitFor(() => findMessages(hud, "").length == 100);
let currentPosition = outputScroller.scrollTop;
const bottom = currentPosition;
EventUtils.sendMouseEvent({type: "click"}, hud.jsterm.inputNode);
// Page up.
EventUtils.synthesizeKey("VK_PAGE_UP", {});
isnot(outputScroller.scrollTop, currentPosition,
"scroll position changed after page up");
// Page down.
currentPosition = outputScroller.scrollTop;
EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
ok(outputScroller.scrollTop > currentPosition,
"scroll position now at bottom");
// Home
EventUtils.synthesizeKey("VK_HOME", {});
is(outputScroller.scrollTop, 0, "scroll position now at top");
// End
EventUtils.synthesizeKey("VK_END", {});
let scrollTop = outputScroller.scrollTop;
ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5,
"scroll position now at bottom");
// Clear output
info("try ctrl-l to clear output");
let clearShortcut;
if (Services.appinfo.OS === "Darwin") {
clearShortcut = WCUL10n.getStr("webconsole.clear.keyOSX");
} else {
clearShortcut = WCUL10n.getStr("webconsole.clear.key");
}
synthesizeKeyShortcut(clearShortcut);
yield waitFor(() => findMessages(hud, "").length == 0);
is(hud.jsterm.inputNode.getAttribute("focused"), "true", "jsterm input is focused");
// Focus filter
info("try ctrl-f to focus filter");
synthesizeKeyShortcut(WCUL10n.getStr("webconsole.find.key"));
ok(!hud.jsterm.inputNode.getAttribute("focused"), "jsterm input is not focused");
is(hud.ui.filterBox, outputScroller.ownerDocument.activeElement,
"filter input is focused");
});
|