browser/metro/base/tests/mochitest/browser_selection_contenteditable.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* Any copyright is dedicated to the Public Domain.
michael@0 4 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 5
michael@0 6 "use strict";
michael@0 7 let gWindow = null;
michael@0 8
michael@0 9 const kCommonWaitMs = 5000;
michael@0 10 const kCommonPollMs = 100;
michael@0 11
michael@0 12 ///////////////////////////////////////////////////
michael@0 13 // content editable tests
michael@0 14 ///////////////////////////////////////////////////
michael@0 15
michael@0 16 gTests.push({
michael@0 17 desc: "normalize browser",
michael@0 18 run: function test() {
michael@0 19 info(chromeRoot + "browser_selection_contenteditable.html");
michael@0 20 yield addTab(chromeRoot + "browser_selection_contenteditable.html");
michael@0 21 yield waitForCondition(function () {
michael@0 22 return !BrowserUI.isStartTabVisible;
michael@0 23 }, kCommonWaitMs, kCommonPollMs);
michael@0 24
michael@0 25 yield hideContextUI();
michael@0 26
michael@0 27 gWindow = Browser.selectedTab.browser.contentWindow;
michael@0 28
michael@0 29 InputSourceHelper.isPrecise = false;
michael@0 30 InputSourceHelper.fireUpdate();
michael@0 31 },
michael@0 32 });
michael@0 33
michael@0 34 gTests.push({
michael@0 35 desc: "simple test to make sure content editable selection works",
michael@0 36 run: function test() {
michael@0 37 let div = gWindow.document.getElementById("testdiv");
michael@0 38 ok(div, "have the div");
michael@0 39
michael@0 40 sendElementTap(gWindow, div, 284); // end of 'outlook.com'
michael@0 41
michael@0 42 yield waitForCondition(function () {
michael@0 43 return SelectionHelperUI.isCaretUIVisible;
michael@0 44 }, kCommonWaitMs, kCommonPollMs);
michael@0 45
michael@0 46 let xpos = SelectionHelperUI.caretMark.xPos;
michael@0 47 let ypos = SelectionHelperUI.caretMark.yPos + 10;
michael@0 48 var touchdrag = new TouchDragAndHold();
michael@0 49 yield touchdrag.start(gWindow, xpos, ypos, 100, ypos); // start of 'sending'
michael@0 50 touchdrag.end();
michael@0 51 yield waitForCondition(function () {
michael@0 52 return !SelectionHelperUI.hasActiveDrag;
michael@0 53 }, kCommonWaitMs, kCommonPollMs);
michael@0 54 yield SelectionHelperUI.pingSelectionHandler();
michael@0 55 let str = getTrimmedSelection(gWindow).toString();
michael@0 56 is(str, "sending an email in the outlook.com", "selected string matches");
michael@0 57 },
michael@0 58 tearDown: function () {
michael@0 59 emptyClipboard();
michael@0 60 if (gWindow)
michael@0 61 clearSelection(gWindow);
michael@0 62 yield waitForCondition(function () {
michael@0 63 return !SelectionHelperUI.isSelectionUIVisible;
michael@0 64 }, kCommonWaitMs, kCommonPollMs);
michael@0 65 }
michael@0 66 });
michael@0 67
michael@0 68 function test() {
michael@0 69 if (!isLandscapeMode()) {
michael@0 70 todo(false, "browser_selection_tests need landscape mode to run.");
michael@0 71 return;
michael@0 72 }
michael@0 73 setDevPixelEqualToPx();
michael@0 74 runTests();
michael@0 75 }

mercurial