toolkit/mozapps/extensions/test/browser/browser_bug570760.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 // Bug 570760 - Make ctrl-f and / focus the search box in the add-ons manager 
     7 var gManagerWindow;
     8 var focusCount = 0;
    10 function test() {
    11   waitForExplicitFinish();
    13   open_manager(null, function(aWindow) {
    14     gManagerWindow = aWindow;
    16     var searchBox = gManagerWindow.document.getElementById("header-search");
    17     function focusHandler() {
    18       searchBox.blur();
    19       focusCount++;
    20     }
    21     searchBox.addEventListener("focus", focusHandler);
    22     f_key_test();
    23     slash_key_test();
    24     searchBox.removeEventListener("focus", focusHandler);
    25     end_test();
    26   });
    27 }
    29 function end_test() {
    30   close_manager(gManagerWindow, finish);
    31 }
    33 function f_key_test() {
    34   EventUtils.synthesizeKey("f", { accelKey: true }, gManagerWindow);
    35   is(focusCount, 1, "Search box should have been focused due to the f key");
    36 }
    38 function slash_key_test() {
    39   EventUtils.synthesizeKey("/", { }, gManagerWindow);
    40   is(focusCount, 2, "Search box should have been focused due to the / key");
    41 }

mercurial