browser/devtools/webconsole/test/browser_console_keyboard_accessibility.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial