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: var gFrame = null; michael@0: michael@0: const kCommonWaitMs = 5000; michael@0: const kCommonPollMs = 100; michael@0: michael@0: /////////////////////////////////////////////////// michael@0: // text area tests michael@0: /////////////////////////////////////////////////// michael@0: michael@0: function setUpAndTearDown() { michael@0: emptyClipboard(); michael@0: if (gWindow) michael@0: clearSelection(gWindow); michael@0: if (gFrame) michael@0: clearSelection(gFrame); michael@0: yield waitForCondition(function () { michael@0: return !SelectionHelperUI.isSelectionUIVisible; michael@0: }, kCommonWaitMs, kCommonPollMs); 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_textarea.html"); michael@0: yield addTab(chromeRoot + "browser_selection_textarea.html"); michael@0: michael@0: yield waitForCondition(function () { michael@0: return !BrowserUI.isStartTabVisible; michael@0: }, 10000, 100); michael@0: michael@0: yield hideContextUI(); michael@0: michael@0: gWindow = Browser.selectedTab.browser.contentWindow; michael@0: }, michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "textarea selection and drag", michael@0: setUp: setUpAndTearDown, michael@0: tearDown: setUpAndTearDown, michael@0: run: function test() { michael@0: // work around for buggy context menu display michael@0: yield waitForMs(100); michael@0: michael@0: let textarea = gWindow.document.getElementById("inputtext"); michael@0: textarea.focus(); michael@0: michael@0: let promise = waitForEvent(document, "popupshown"); michael@0: sendContextMenuClickToElement(gWindow, textarea, 20, 10); michael@0: yield promise; michael@0: michael@0: checkContextUIMenuItemVisibility(["context-select", michael@0: "context-select-all"]); michael@0: michael@0: let menuItem = document.getElementById("context-select"); michael@0: ok(menuItem, "menu item exists"); michael@0: ok(!menuItem.hidden, "menu item visible"); michael@0: let popupPromise = waitForEvent(document, "popuphidden"); michael@0: sendElementTap(gWindow, menuItem); michael@0: yield popupPromise; michael@0: ok(popupPromise && !(popupPromise instanceof Error), "promise error"); michael@0: michael@0: yield waitForCondition(function () { michael@0: return SelectionHelperUI.isSelectionUIVisible; michael@0: }, kCommonWaitMs, kCommonPollMs); michael@0: michael@0: is(SelectionHelperUI.isActive, true, "selection active"); michael@0: is(getTrimmedSelection(textarea).toString(), "Alice", "selection test"); michael@0: michael@0: let xpos = SelectionHelperUI.endMark.xPos; michael@0: let ypos = SelectionHelperUI.endMark.yPos + 10; michael@0: michael@0: var touchdrag = new TouchDragAndHold(); michael@0: michael@0: // end marker and off the text area to the right michael@0: yield touchdrag.start(gWindow, xpos, ypos, 1200, 400); michael@0: let token = "(end)"; michael@0: yield waitForCondition(function () { michael@0: let selection = getTrimmedSelection(textarea).toString(); michael@0: if (selection.length < token.length || michael@0: selection.substring(selection.length - token.length) != token) { michael@0: return false; michael@0: } michael@0: return true; michael@0: }, 5000, 100); michael@0: michael@0: touchdrag.end(); michael@0: touchdrag = null; michael@0: michael@0: yield waitForCondition(function () { michael@0: return !SelectionHelperUI.hasActiveDrag; michael@0: }, kCommonWaitMs, kCommonPollMs); michael@0: yield SelectionHelperUI.pingSelectionHandler(); 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: runTests(); michael@0: }