1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/base/tests/mochitest/browser_selection_caretfocus.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* Any copyright is dedicated to the Public Domain. 1.7 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.8 + 1.9 +"use strict"; 1.10 + 1.11 +let gWindow = null; 1.12 + 1.13 +/////////////////////////////////////////////////// 1.14 +// form input tests 1.15 +/////////////////////////////////////////////////// 1.16 + 1.17 +function setUpAndTearDown() { 1.18 + emptyClipboard(); 1.19 + if (gWindow) 1.20 + clearSelection(gWindow); 1.21 + yield waitForCondition(function () { 1.22 + return !SelectionHelperUI.isSelectionUIVisible; 1.23 + }); 1.24 + InputSourceHelper.isPrecise = false; 1.25 + InputSourceHelper.fireUpdate(); 1.26 +} 1.27 + 1.28 +gTests.push({ 1.29 + desc: "normalize browser", 1.30 + setUp: setUpAndTearDown, 1.31 + tearDown: setUpAndTearDown, 1.32 + run: function test() { 1.33 + info(chromeRoot + "browser_selection_caretfocus.html"); 1.34 + yield addTab(chromeRoot + "browser_selection_caretfocus.html"); 1.35 + 1.36 + yield waitForCondition(function () { 1.37 + return !BrowserUI.isStartTabVisible; 1.38 + }); 1.39 + 1.40 + yield hideContextUI(); 1.41 + 1.42 + gWindow = Browser.selectedTab.browser.contentWindow; 1.43 + }, 1.44 +}); 1.45 + 1.46 +function tapText(aIndex) { 1.47 + gWindow = Browser.selectedTab.browser.contentWindow; 1.48 + let id = "Text" + aIndex; 1.49 + info("tapping " + id); 1.50 + let element = gWindow.document.getElementById(id); 1.51 + if (element.contentDocument) { 1.52 + element = element.contentDocument.getElementById("textarea"); 1.53 + gWindow = element.ownerDocument.defaultView; 1.54 + } 1.55 + sendElementTap(gWindow, element, 100, 10); 1.56 + return element; 1.57 +} 1.58 + 1.59 +gTests.push({ 1.60 + desc: "focus navigation", 1.61 + setUp: setUpAndTearDown, 1.62 + tearDown: setUpAndTearDown, 1.63 + run: function test() { 1.64 + for (let iteration = 0; iteration < 3; iteration++) { 1.65 + for (let input = 1; input <= 6; input++) { 1.66 + let element = tapText(input); 1.67 + if (input == 6) { 1.68 + // div 1.69 + yield waitForCondition(function () { 1.70 + return !SelectionHelperUI.isActive; 1.71 + }); 1.72 + } else { 1.73 + // input 1.74 + yield SelectionHelperUI.pingSelectionHandler(); 1.75 + yield waitForCondition(function () { 1.76 + return SelectionHelperUI.isCaretUIVisible; 1.77 + }); 1.78 + ok(element == gWindow.document.activeElement, "element has focus"); 1.79 + } 1.80 + } 1.81 + } 1.82 + }, 1.83 +}); 1.84 + 1.85 +function test() { 1.86 + if (!isLandscapeMode()) { 1.87 + todo(false, "browser_selection_tests need landscape mode to run."); 1.88 + return; 1.89 + } 1.90 + // XXX need this until bugs 886624 and 859742 are fully resolved 1.91 + setDevPixelEqualToPx(); 1.92 + runTests(); 1.93 +}