|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 // Check that basic keyboard shortcuts work in the web console. |
|
7 |
|
8 function test() |
|
9 { |
|
10 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; |
|
11 let hud = null; |
|
12 |
|
13 addTab(TEST_URI); |
|
14 |
|
15 browser.addEventListener("load", function onLoad() { |
|
16 browser.removeEventListener("load", onLoad, true); |
|
17 openConsole(null, consoleOpened); |
|
18 }, true); |
|
19 |
|
20 function consoleOpened(aHud) |
|
21 { |
|
22 hud = aHud; |
|
23 ok(hud, "Web Console opened"); |
|
24 |
|
25 info("dump some spew into the console for scrolling"); |
|
26 for (let i = 0; i < 100; i++) |
|
27 content.console.log("foobarz" + i); |
|
28 waitForMessages({ |
|
29 webconsole: hud, |
|
30 messages: [{ |
|
31 text: "foobarz99", |
|
32 category: CATEGORY_WEBDEV, |
|
33 severity: SEVERITY_LOG, |
|
34 }], |
|
35 }).then(onConsoleMessage); |
|
36 } |
|
37 |
|
38 function onConsoleMessage() |
|
39 { |
|
40 let currentPosition = hud.outputNode.parentNode.scrollTop; |
|
41 EventUtils.synthesizeKey("VK_PAGE_UP", {}); |
|
42 isnot(hud.outputNode.parentNode.scrollTop, currentPosition, "scroll position changed after page up"); |
|
43 |
|
44 currentPosition = hud.outputNode.parentNode.scrollTop; |
|
45 EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); |
|
46 ok(hud.outputNode.parentNode.scrollTop > currentPosition, "scroll position now at bottom"); |
|
47 |
|
48 hud.jsterm.once("messages-cleared", onClear); |
|
49 info("try ctrl-l to clear output"); |
|
50 EventUtils.synthesizeKey("l", { ctrlKey: true }); |
|
51 } |
|
52 |
|
53 function onClear() |
|
54 { |
|
55 is(hud.outputNode.textContent.indexOf("foobarz1"), -1, "output cleared"); |
|
56 is(hud.jsterm.inputNode.getAttribute("focused"), "true", |
|
57 "jsterm input is focused"); |
|
58 |
|
59 info("try ctrl-f to focus filter"); |
|
60 EventUtils.synthesizeKey("F", { accelKey: true }); |
|
61 ok(!hud.jsterm.inputNode.getAttribute("focused"), |
|
62 "jsterm input is not focused"); |
|
63 is(hud.ui.filterBox.getAttribute("focused"), "true", |
|
64 "filter input is focused"); |
|
65 |
|
66 if (Services.appinfo.OS == "Darwin") { |
|
67 ok(hud.ui.getFilterState("network"), "network category is enabled"); |
|
68 EventUtils.synthesizeKey("t", { ctrlKey: true }); |
|
69 ok(!hud.ui.getFilterState("network"), "accesskey for Network works"); |
|
70 EventUtils.synthesizeKey("t", { ctrlKey: true }); |
|
71 ok(hud.ui.getFilterState("network"), "accesskey for Network works (again)"); |
|
72 } |
|
73 else { |
|
74 EventUtils.synthesizeKey("N", { altKey: true }); |
|
75 let net = hud.ui.document.querySelector("toolbarbutton[category=net]"); |
|
76 is(hud.ui.document.activeElement, net, |
|
77 "accesskey for Network category focuses the Net button"); |
|
78 } |
|
79 |
|
80 finishTest(); |
|
81 } |
|
82 } |