michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Check that basic keyboard shortcuts work in the web console. michael@0: michael@0: function test() michael@0: { michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; michael@0: let hud = null; michael@0: michael@0: addTab(TEST_URI); michael@0: michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, consoleOpened); michael@0: }, true); michael@0: michael@0: function consoleOpened(aHud) michael@0: { michael@0: hud = aHud; michael@0: ok(hud, "Web Console opened"); michael@0: michael@0: info("dump some spew into the console for scrolling"); michael@0: for (let i = 0; i < 100; i++) michael@0: content.console.log("foobarz" + i); michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "foobarz99", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: }], michael@0: }).then(onConsoleMessage); michael@0: } michael@0: michael@0: function onConsoleMessage() michael@0: { michael@0: let currentPosition = hud.outputNode.parentNode.scrollTop; michael@0: EventUtils.synthesizeKey("VK_PAGE_UP", {}); michael@0: isnot(hud.outputNode.parentNode.scrollTop, currentPosition, "scroll position changed after page up"); michael@0: michael@0: currentPosition = hud.outputNode.parentNode.scrollTop; michael@0: EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); michael@0: ok(hud.outputNode.parentNode.scrollTop > currentPosition, "scroll position now at bottom"); michael@0: michael@0: hud.jsterm.once("messages-cleared", onClear); michael@0: info("try ctrl-l to clear output"); michael@0: EventUtils.synthesizeKey("l", { ctrlKey: true }); michael@0: } michael@0: michael@0: function onClear() michael@0: { michael@0: is(hud.outputNode.textContent.indexOf("foobarz1"), -1, "output cleared"); michael@0: is(hud.jsterm.inputNode.getAttribute("focused"), "true", michael@0: "jsterm input is focused"); michael@0: michael@0: info("try ctrl-f to focus filter"); michael@0: EventUtils.synthesizeKey("F", { accelKey: true }); michael@0: ok(!hud.jsterm.inputNode.getAttribute("focused"), michael@0: "jsterm input is not focused"); michael@0: is(hud.ui.filterBox.getAttribute("focused"), "true", michael@0: "filter input is focused"); michael@0: michael@0: if (Services.appinfo.OS == "Darwin") { michael@0: ok(hud.ui.getFilterState("network"), "network category is enabled"); michael@0: EventUtils.synthesizeKey("t", { ctrlKey: true }); michael@0: ok(!hud.ui.getFilterState("network"), "accesskey for Network works"); michael@0: EventUtils.synthesizeKey("t", { ctrlKey: true }); michael@0: ok(hud.ui.getFilterState("network"), "accesskey for Network works (again)"); michael@0: } michael@0: else { michael@0: EventUtils.synthesizeKey("N", { altKey: true }); michael@0: let net = hud.ui.document.querySelector("toolbarbutton[category=net]"); michael@0: is(hud.ui.document.activeElement, net, michael@0: "accesskey for Network category focuses the Net button"); michael@0: } michael@0: michael@0: finishTest(); michael@0: } michael@0: }