browser/metro/base/tests/mochitest/browser_selection_caretfocus.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 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* Any copyright is dedicated to the Public Domain.
     4    http://creativecommons.org/publicdomain/zero/1.0/ */
     6 "use strict";
     8 let gWindow = null;
    10 ///////////////////////////////////////////////////
    11 // form input tests
    12 ///////////////////////////////////////////////////
    14 function setUpAndTearDown() {
    15   emptyClipboard();
    16   if (gWindow)
    17     clearSelection(gWindow);
    18   yield waitForCondition(function () {
    19     return !SelectionHelperUI.isSelectionUIVisible;
    20   });
    21   InputSourceHelper.isPrecise = false;
    22   InputSourceHelper.fireUpdate();
    23 }
    25 gTests.push({
    26   desc: "normalize browser",
    27   setUp: setUpAndTearDown,
    28   tearDown: setUpAndTearDown,
    29   run: function test() {
    30     info(chromeRoot + "browser_selection_caretfocus.html");
    31     yield addTab(chromeRoot + "browser_selection_caretfocus.html");
    33     yield waitForCondition(function () {
    34       return !BrowserUI.isStartTabVisible;
    35     });
    37     yield hideContextUI();
    39     gWindow = Browser.selectedTab.browser.contentWindow;
    40   },
    41 });
    43 function tapText(aIndex) {
    44   gWindow = Browser.selectedTab.browser.contentWindow;
    45   let id = "Text" + aIndex;
    46   info("tapping " + id);
    47   let element = gWindow.document.getElementById(id);
    48   if (element.contentDocument) {
    49     element = element.contentDocument.getElementById("textarea");
    50     gWindow = element.ownerDocument.defaultView;
    51   }
    52   sendElementTap(gWindow, element, 100, 10);
    53   return element;
    54 }
    56 gTests.push({
    57   desc: "focus navigation",
    58   setUp: setUpAndTearDown,
    59   tearDown: setUpAndTearDown,
    60   run: function test() {
    61     for (let iteration = 0; iteration < 3; iteration++) {
    62       for (let input = 1; input <= 6; input++) {
    63         let element = tapText(input);
    64         if (input == 6) {
    65           // div
    66           yield waitForCondition(function () {
    67             return !SelectionHelperUI.isActive;
    68           });
    69         } else {
    70           // input
    71           yield SelectionHelperUI.pingSelectionHandler();
    72           yield waitForCondition(function () {
    73             return SelectionHelperUI.isCaretUIVisible;
    74           });
    75           ok(element == gWindow.document.activeElement, "element has focus");
    76         }
    77       }
    78     }
    79   },
    80 });
    82 function test() {
    83   if (!isLandscapeMode()) {
    84     todo(false, "browser_selection_tests need landscape mode to run.");
    85     return;
    86   }
    87   // XXX need this until bugs 886624 and 859742 are fully resolved
    88   setDevPixelEqualToPx();
    89   runTests();
    90 }

mercurial