Bug 863748 - Add subframe text input selection tests. r=rsilveira

This commit is contained in:
Jim Mathies 2013-04-23 16:44:07 -05:00
Родитель 6409e7817c
Коммит 0a21fd4aa5
4 изменённых файлов: 261 добавлений и 0 удалений

Просмотреть файл

@ -47,12 +47,15 @@ BROWSER_TESTS += \
browser_selection_inputs.html \ browser_selection_inputs.html \
browser_selection_frame_textarea.js \ browser_selection_frame_textarea.js \
browser_selection_frame_textarea.html \ browser_selection_frame_textarea.html \
browser_selection_frame_inputs.js \
browser_selection_frame_inputs.html \
$(NULL) $(NULL)
endif endif
BROWSER_TEST_RESOURCES = \ BROWSER_TEST_RESOURCES = \
res/image01.png \ res/image01.png \
res/textblock01.html \ res/textblock01.html \
res/textinput01.html \
$(NULL) $(NULL)
libs:: $(BROWSER_TESTS) libs:: $(BROWSER_TESTS)

Просмотреть файл

@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body style="margin: 5px 5px 5px 85px;">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div><p>
<iframe id="frame1" style="border: 0px;" height="200" src="res/textinput01.html" width="600"></iframe>
</p></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</body>
</html>

Просмотреть файл

@ -0,0 +1,162 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
let gWindow = null;
var gFrame = null;
var gInput = null;
const kMarkerOffsetY = 12;
const kCommonWaitMs = 5000;
const kCommonPollMs = 100;
///////////////////////////////////////////////////
// form input tests
///////////////////////////////////////////////////
function setUpAndTearDown() {
emptyClipboard();
if (gWindow)
clearSelection(gWindow);
if (gFrame)
clearSelection(gFrame);
if (gInput)
clearSelection(gInput);
yield waitForCondition(function () {
return !SelectionHelperUI.isSelectionUIVisible;
}, kCommonWaitMs, kCommonPollMs);
}
gTests.push({
desc: "normalize browser",
setUp: setUpAndTearDown,
tearDown: setUpAndTearDown,
run: function test() {
info(chromeRoot + "browser_selection_frame_inputs.html");
yield addTab(chromeRoot + "browser_selection_frame_inputs.html");
yield waitForCondition(function () {
return !StartUI.isStartPageVisible;
}, 10000, 100);
yield hideContextUI();
gWindow = Browser.selectedTab.browser.contentWindow;
gFrame = gWindow.document.getElementById("frame1");
gInput = gFrame.contentDocument.getElementById("textinput");
ok(gWindow != null, "gWindow");
ok(gFrame != null, "gFrame");
ok(gInput != null, "gInput");
InputSourceHelper.isPrecise = false;
},
});
gTests.push({
desc: "basic selection",
setUp: setUpAndTearDown,
tearDown: setUpAndTearDown,
run: function test() {
gInput.focus();
gInput.selectionStart = gInput.selectionEnd = 0;
let promise = waitForEvent(document, "popupshown");
sendContextMenuClick(232, 583);
yield promise;
checkContextUIMenuItemVisibility(["context-select",
"context-select-all"]);
let menuItem = document.getElementById("context-select");
ok(menuItem, "menu item exists");
ok(!menuItem.hidden, "menu item visible");
let popupPromise = waitForEvent(document, "popuphidden");
EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
yield popupPromise;
yield waitForCondition(function () {
return SelectionHelperUI.isSelectionUIVisible;
}, kCommonWaitMs, kCommonPollMs);
is(getTrimmedSelection(gInput).toString(), "straight", "selection test");
checkMonoclePositionRange("start", 210, 220, 600, 605);
checkMonoclePositionRange("end", 250, 260, 600, 605);
},
});
gTests.push({
desc: "drag selection",
setUp: setUpAndTearDown,
tearDown: setUpAndTearDown,
run: function test() {
gInput.focus();
gInput.selectionStart = gInput.selectionEnd = 0;
let promise = waitForEvent(document, "popupshown");
sendContextMenuClick(232, 583);
yield promise;
checkContextUIMenuItemVisibility(["context-select",
"context-select-all"]);
let menuItem = document.getElementById("context-select");
ok(menuItem, "menu item exists");
ok(!menuItem.hidden, "menu item visible");
let popupPromise = waitForEvent(document, "popuphidden");
EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
yield popupPromise;
yield waitForCondition(function () {
return SelectionHelperUI.isSelectionUIVisible;
}, kCommonWaitMs, kCommonPollMs);
is(getTrimmedSelection(gInput).toString(), "straight", "selection test");
// end marker to the right
let xpos = SelectionHelperUI.endMark.xPos;
let ypos = SelectionHelperUI.endMark.yPos + 10;
var touchdrag = new TouchDragAndHold();
yield touchdrag.start(gWindow, xpos, ypos, xpos + 350, ypos);
yield waitForCondition(function () {
return getTrimmedSelection(gInput).toString() ==
"straight on like a tunnel for some way and then dipped suddenly down";
}, 6000, 2000);
touchdrag.end();
yield waitForCondition(function () {
return !SelectionHelperUI.hasActiveDrag;
}, kCommonWaitMs, kCommonPollMs);
yield SelectionHelperUI.pingSelectionHandler();
// start marker to the left
let xpos = SelectionHelperUI.startMark.xPos;
let ypos = SelectionHelperUI.startMark.yPos + 10;
var touchdrag = new TouchDragAndHold();
yield touchdrag.start(gWindow, xpos, ypos, 10, ypos);
yield waitForCondition(function () {
return getTrimmedSelection(gInput).toString() ==
"The rabbit-hole went straight on like a tunnel for some way and then dipped suddenly down";
}, 6000, 2000);
touchdrag.end();
yield waitForCondition(function () {
return !SelectionHelperUI.hasActiveDrag;
}, kCommonWaitMs, kCommonPollMs);
yield SelectionHelperUI.pingSelectionHandler();
},
});
function test() {
if (!isLandscapeMode()) {
todo(false, "browser_selection_tests need landscape mode to run.");
return;
}
requestLongerTimeout(3);
runTests();
}

Просмотреть файл

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<input id="textinput" style="width:300px; height:25px;" value="The rabbit-hole went straight on like a tunnel for some way and then dipped suddenly down" type="text">
</body>
</html>