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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/metro/base/tests/mochitest/browser_selection_contenteditable.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     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 +let gWindow = null;
    1.11 +
    1.12 +const kCommonWaitMs = 5000;
    1.13 +const kCommonPollMs = 100;
    1.14 +
    1.15 +///////////////////////////////////////////////////
    1.16 +// content editable tests
    1.17 +///////////////////////////////////////////////////
    1.18 +
    1.19 +gTests.push({
    1.20 +  desc: "normalize browser",
    1.21 +  run: function test() {
    1.22 +    info(chromeRoot + "browser_selection_contenteditable.html");
    1.23 +    yield addTab(chromeRoot + "browser_selection_contenteditable.html");
    1.24 +    yield waitForCondition(function () {
    1.25 +        return !BrowserUI.isStartTabVisible;
    1.26 +      }, kCommonWaitMs, kCommonPollMs);
    1.27 +
    1.28 +    yield hideContextUI();
    1.29 +
    1.30 +    gWindow = Browser.selectedTab.browser.contentWindow;
    1.31 +
    1.32 +    InputSourceHelper.isPrecise = false;
    1.33 +    InputSourceHelper.fireUpdate();
    1.34 +  },
    1.35 +});
    1.36 +
    1.37 +gTests.push({
    1.38 +  desc: "simple test to make sure content editable selection works",
    1.39 +  run: function test() {
    1.40 +    let div = gWindow.document.getElementById("testdiv");
    1.41 +    ok(div, "have the div");
    1.42 +
    1.43 +    sendElementTap(gWindow, div, 284); // end of 'outlook.com'
    1.44 +
    1.45 +    yield waitForCondition(function () {
    1.46 +        return SelectionHelperUI.isCaretUIVisible;
    1.47 +      }, kCommonWaitMs, kCommonPollMs);
    1.48 +
    1.49 +    let xpos = SelectionHelperUI.caretMark.xPos;
    1.50 +    let ypos = SelectionHelperUI.caretMark.yPos + 10;
    1.51 +    var touchdrag = new TouchDragAndHold();
    1.52 +    yield touchdrag.start(gWindow, xpos, ypos, 100, ypos); // start of 'sending'
    1.53 +    touchdrag.end();
    1.54 +    yield waitForCondition(function () {
    1.55 +        return !SelectionHelperUI.hasActiveDrag;
    1.56 +      }, kCommonWaitMs, kCommonPollMs);
    1.57 +    yield SelectionHelperUI.pingSelectionHandler();
    1.58 +    let str = getTrimmedSelection(gWindow).toString();
    1.59 +    is(str, "sending an email in the outlook.com", "selected string matches");
    1.60 +  },
    1.61 +  tearDown: function () {
    1.62 +    emptyClipboard();
    1.63 +    if (gWindow)
    1.64 +      clearSelection(gWindow);
    1.65 +    yield waitForCondition(function () {
    1.66 +      return !SelectionHelperUI.isSelectionUIVisible;
    1.67 +    }, kCommonWaitMs, kCommonPollMs);
    1.68 +  }
    1.69 +});
    1.70 +
    1.71 +function test() {
    1.72 +  if (!isLandscapeMode()) {
    1.73 +    todo(false, "browser_selection_tests need landscape mode to run.");
    1.74 +    return;
    1.75 +  }
    1.76 +  setDevPixelEqualToPx();
    1.77 +  runTests();
    1.78 +}

mercurial