browser/devtools/scratchpad/test/browser_scratchpad_help_key.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 /* vim: set ts=2 et sw=2 tw=80: */
     2 /* Any copyright is dedicated to the Public Domain.
     3    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /* Bug 650760 */
     6 function test()
     7 {
     8   waitForExplicitFinish();
    10   gBrowser.selectedTab = gBrowser.addTab();
    11   content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760";
    12   gBrowser.selectedBrowser.addEventListener("load", function onTabLoad() {
    13     gBrowser.selectedBrowser.removeEventListener("load", onTabLoad, true);
    15     ok(window.Scratchpad, "Scratchpad variable exists");
    17     openScratchpad(runTest);
    18   }, true);
    19 }
    21 function runTest()
    22 {
    23   let sp = gScratchpadWindow.Scratchpad;
    24   ok(sp, "Scratchpad object exists in new window");
    25   ok(sp.editor.hasFocus(), "the editor has focus");
    27   let keyid = gScratchpadWindow.document.getElementById("key_openHelp");
    28   let modifiers = keyid.getAttribute("modifiers");
    30   let key = null;
    31   if (keyid.getAttribute("keycode"))
    32     key = keyid.getAttribute("keycode");
    34   else if (keyid.getAttribute("key"))
    35     key = keyid.getAttribute("key");
    37   isnot(key, null, "Successfully retrieved keycode/key");
    39   var aEvent = {
    40     shiftKey: modifiers.match("shift"),
    41     ctrlKey: modifiers.match("ctrl"),
    42     altKey: modifiers.match("alt"),
    43     metaKey: modifiers.match("meta"),
    44     accelKey: modifiers.match("accel")
    45   }
    47   info("check that the MDN page is opened on \"F1\"");
    48   let linkClicked = false;
    49   sp.openDocumentationPage = function(event) { linkClicked = true; };
    51   EventUtils.synthesizeKey(key, aEvent, gScratchpadWindow);
    53   is(linkClicked, true, "MDN page will open");
    54   finishTest();
    55 }
    57 function finishTest()
    58 {
    59   gScratchpadWindow.close();
    60   finish();
    61 }

mercurial