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: let gWindow = null; michael@0: michael@0: const kCommonWaitMs = 5000; michael@0: const kCommonPollMs = 100; michael@0: michael@0: /////////////////////////////////////////////////// michael@0: // content editable tests michael@0: /////////////////////////////////////////////////// michael@0: michael@0: gTests.push({ michael@0: desc: "normalize browser", michael@0: run: function test() { michael@0: info(chromeRoot + "browser_selection_contenteditable.html"); michael@0: yield addTab(chromeRoot + "browser_selection_contenteditable.html"); michael@0: yield waitForCondition(function () { michael@0: return !BrowserUI.isStartTabVisible; michael@0: }, kCommonWaitMs, kCommonPollMs); michael@0: michael@0: yield hideContextUI(); michael@0: michael@0: gWindow = Browser.selectedTab.browser.contentWindow; michael@0: michael@0: InputSourceHelper.isPrecise = false; michael@0: InputSourceHelper.fireUpdate(); michael@0: }, michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "simple test to make sure content editable selection works", michael@0: run: function test() { michael@0: let div = gWindow.document.getElementById("testdiv"); michael@0: ok(div, "have the div"); michael@0: michael@0: sendElementTap(gWindow, div, 284); // end of 'outlook.com' michael@0: michael@0: yield waitForCondition(function () { michael@0: return SelectionHelperUI.isCaretUIVisible; michael@0: }, kCommonWaitMs, kCommonPollMs); michael@0: michael@0: let xpos = SelectionHelperUI.caretMark.xPos; michael@0: let ypos = SelectionHelperUI.caretMark.yPos + 10; michael@0: var touchdrag = new TouchDragAndHold(); michael@0: yield touchdrag.start(gWindow, xpos, ypos, 100, ypos); // start of 'sending' michael@0: touchdrag.end(); michael@0: yield waitForCondition(function () { michael@0: return !SelectionHelperUI.hasActiveDrag; michael@0: }, kCommonWaitMs, kCommonPollMs); michael@0: yield SelectionHelperUI.pingSelectionHandler(); michael@0: let str = getTrimmedSelection(gWindow).toString(); michael@0: is(str, "sending an email in the outlook.com", "selected string matches"); michael@0: }, michael@0: tearDown: function () { michael@0: emptyClipboard(); michael@0: if (gWindow) michael@0: clearSelection(gWindow); michael@0: yield waitForCondition(function () { michael@0: return !SelectionHelperUI.isSelectionUIVisible; michael@0: }, kCommonWaitMs, kCommonPollMs); 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: setDevPixelEqualToPx(); michael@0: runTests(); michael@0: }