michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: let gWindow = null; michael@0: michael@0: /////////////////////////////////////////////////// michael@0: // form input tests michael@0: /////////////////////////////////////////////////// michael@0: michael@0: function setUpAndTearDown() { michael@0: emptyClipboard(); michael@0: if (gWindow) michael@0: clearSelection(gWindow); michael@0: yield waitForCondition(function () { michael@0: return !SelectionHelperUI.isSelectionUIVisible; michael@0: }); michael@0: InputSourceHelper.isPrecise = false; michael@0: InputSourceHelper.fireUpdate(); michael@0: } michael@0: michael@0: gTests.push({ michael@0: desc: "normalize browser", michael@0: setUp: setUpAndTearDown, michael@0: tearDown: setUpAndTearDown, michael@0: run: function test() { michael@0: info(chromeRoot + "browser_selection_caretfocus.html"); michael@0: yield addTab(chromeRoot + "browser_selection_caretfocus.html"); michael@0: michael@0: yield waitForCondition(function () { michael@0: return !BrowserUI.isStartTabVisible; michael@0: }); michael@0: michael@0: yield hideContextUI(); michael@0: michael@0: gWindow = Browser.selectedTab.browser.contentWindow; michael@0: }, michael@0: }); michael@0: michael@0: function tapText(aIndex) { michael@0: gWindow = Browser.selectedTab.browser.contentWindow; michael@0: let id = "Text" + aIndex; michael@0: info("tapping " + id); michael@0: let element = gWindow.document.getElementById(id); michael@0: if (element.contentDocument) { michael@0: element = element.contentDocument.getElementById("textarea"); michael@0: gWindow = element.ownerDocument.defaultView; michael@0: } michael@0: sendElementTap(gWindow, element, 100, 10); michael@0: return element; michael@0: } michael@0: michael@0: gTests.push({ michael@0: desc: "focus navigation", michael@0: setUp: setUpAndTearDown, michael@0: tearDown: setUpAndTearDown, michael@0: run: function test() { michael@0: for (let iteration = 0; iteration < 3; iteration++) { michael@0: for (let input = 1; input <= 6; input++) { michael@0: let element = tapText(input); michael@0: if (input == 6) { michael@0: // div michael@0: yield waitForCondition(function () { michael@0: return !SelectionHelperUI.isActive; michael@0: }); michael@0: } else { michael@0: // input michael@0: yield SelectionHelperUI.pingSelectionHandler(); michael@0: yield waitForCondition(function () { michael@0: return SelectionHelperUI.isCaretUIVisible; michael@0: }); michael@0: ok(element == gWindow.document.activeElement, "element has focus"); michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: }); michael@0: michael@0: function test() { michael@0: if (!isLandscapeMode()) { michael@0: todo(false, "browser_selection_tests need landscape mode to run."); michael@0: return; michael@0: } michael@0: // XXX need this until bugs 886624 and 859742 are fully resolved michael@0: setDevPixelEqualToPx(); michael@0: runTests(); michael@0: }