1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_console_keyboard_accessibility.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.7 + */ 1.8 + 1.9 +// Check that basic keyboard shortcuts work in the web console. 1.10 + 1.11 +function test() 1.12 +{ 1.13 + const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; 1.14 + let hud = null; 1.15 + 1.16 + addTab(TEST_URI); 1.17 + 1.18 + browser.addEventListener("load", function onLoad() { 1.19 + browser.removeEventListener("load", onLoad, true); 1.20 + openConsole(null, consoleOpened); 1.21 + }, true); 1.22 + 1.23 + function consoleOpened(aHud) 1.24 + { 1.25 + hud = aHud; 1.26 + ok(hud, "Web Console opened"); 1.27 + 1.28 + info("dump some spew into the console for scrolling"); 1.29 + for (let i = 0; i < 100; i++) 1.30 + content.console.log("foobarz" + i); 1.31 + waitForMessages({ 1.32 + webconsole: hud, 1.33 + messages: [{ 1.34 + text: "foobarz99", 1.35 + category: CATEGORY_WEBDEV, 1.36 + severity: SEVERITY_LOG, 1.37 + }], 1.38 + }).then(onConsoleMessage); 1.39 + } 1.40 + 1.41 + function onConsoleMessage() 1.42 + { 1.43 + let currentPosition = hud.outputNode.parentNode.scrollTop; 1.44 + EventUtils.synthesizeKey("VK_PAGE_UP", {}); 1.45 + isnot(hud.outputNode.parentNode.scrollTop, currentPosition, "scroll position changed after page up"); 1.46 + 1.47 + currentPosition = hud.outputNode.parentNode.scrollTop; 1.48 + EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); 1.49 + ok(hud.outputNode.parentNode.scrollTop > currentPosition, "scroll position now at bottom"); 1.50 + 1.51 + hud.jsterm.once("messages-cleared", onClear); 1.52 + info("try ctrl-l to clear output"); 1.53 + EventUtils.synthesizeKey("l", { ctrlKey: true }); 1.54 + } 1.55 + 1.56 + function onClear() 1.57 + { 1.58 + is(hud.outputNode.textContent.indexOf("foobarz1"), -1, "output cleared"); 1.59 + is(hud.jsterm.inputNode.getAttribute("focused"), "true", 1.60 + "jsterm input is focused"); 1.61 + 1.62 + info("try ctrl-f to focus filter"); 1.63 + EventUtils.synthesizeKey("F", { accelKey: true }); 1.64 + ok(!hud.jsterm.inputNode.getAttribute("focused"), 1.65 + "jsterm input is not focused"); 1.66 + is(hud.ui.filterBox.getAttribute("focused"), "true", 1.67 + "filter input is focused"); 1.68 + 1.69 + if (Services.appinfo.OS == "Darwin") { 1.70 + ok(hud.ui.getFilterState("network"), "network category is enabled"); 1.71 + EventUtils.synthesizeKey("t", { ctrlKey: true }); 1.72 + ok(!hud.ui.getFilterState("network"), "accesskey for Network works"); 1.73 + EventUtils.synthesizeKey("t", { ctrlKey: true }); 1.74 + ok(hud.ui.getFilterState("network"), "accesskey for Network works (again)"); 1.75 + } 1.76 + else { 1.77 + EventUtils.synthesizeKey("N", { altKey: true }); 1.78 + let net = hud.ui.document.querySelector("toolbarbutton[category=net]"); 1.79 + is(hud.ui.document.activeElement, net, 1.80 + "accesskey for Network category focuses the Net button"); 1.81 + } 1.82 + 1.83 + finishTest(); 1.84 + } 1.85 +}