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.

     1 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/publicdomain/zero/1.0/
     4  */
     6 // Check that basic keyboard shortcuts work in the web console.
     8 function test()
     9 {
    10   const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
    11   let hud = null;
    13   addTab(TEST_URI);
    15   browser.addEventListener("load", function onLoad() {
    16     browser.removeEventListener("load", onLoad, true);
    17     openConsole(null, consoleOpened);
    18   }, true);
    20   function consoleOpened(aHud)
    21   {
    22     hud = aHud;
    23     ok(hud, "Web Console opened");
    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   }
    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");
    44     currentPosition = hud.outputNode.parentNode.scrollTop;
    45     EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
    46     ok(hud.outputNode.parentNode.scrollTop > currentPosition, "scroll position now at bottom");
    48     hud.jsterm.once("messages-cleared", onClear);
    49     info("try ctrl-l to clear output");
    50     EventUtils.synthesizeKey("l", { ctrlKey: true });
    51   }
    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");
    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");
    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     }
    80     finishTest();
    81   }
    82 }

mercurial