зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1125527 - merge the common code of tests. r=margaret
This commit is contained in:
Родитель
b77dfb066d
Коммит
9022f46bfb
|
@ -0,0 +1,126 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import('resource://gre/modules/Geometry.jsm');
|
||||
|
||||
/* ============================== Utility functions ================================================
|
||||
*
|
||||
* Common functions available to all tests.
|
||||
*
|
||||
*/
|
||||
function getSelectionHandler() {
|
||||
return (!this._selectionHandler) ?
|
||||
this._selectionHandler = Services.wm.getMostRecentWindow("navigator:browser").SelectionHandler :
|
||||
this._selectionHandler;
|
||||
}
|
||||
|
||||
function todo(result, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
todo: result,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function ok(result, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: result,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function is(one, two, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: one === two,
|
||||
msg: msg + " : " + one + " === " + two
|
||||
});
|
||||
}
|
||||
|
||||
function isNot(one, two, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: one !== two,
|
||||
msg: msg + " : " + one + " !== " + two
|
||||
});
|
||||
}
|
||||
|
||||
function lessThan(n1, n2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: n1 < n2,
|
||||
msg: msg + " : " + n1 + " < " + n2
|
||||
});
|
||||
}
|
||||
|
||||
function greaterThan(n1, n2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: n1 > n2,
|
||||
msg: msg + " : " + n1 + " > " + n2
|
||||
});
|
||||
}
|
||||
|
||||
// Use fuzzy logic to compare screen coords.
|
||||
function truncPoint(point) {
|
||||
return new Point(Math.trunc(point.x), Math.trunc(point.y));
|
||||
}
|
||||
|
||||
function pointEquals(p1, p2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: truncPoint(p1).equals(truncPoint(p2)),
|
||||
msg: msg + " : " + p1.toString() + " == " + p2.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function pointNotEquals(p1, p2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: !truncPoint(p1).equals(truncPoint(p2)),
|
||||
msg: msg + " : " + p1.toString() + " == " + p2.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function selectionExists(selection, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: !truncPoint(selection.anchorPt).equals(truncPoint(selection.focusPt)),
|
||||
msg: msg + " : anchor:" + selection.anchorPt.toString() +
|
||||
" focus:" + selection.focusPt.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function selectionEquals(s1, s2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: TYPE_NAME,
|
||||
result: truncPoint(s1.anchorPt).equals(truncPoint(s2.anchorPt)) &&
|
||||
truncPoint(s1.focusPt).equals(truncPoint(s2.focusPt)),
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
/* =================================================================================================
|
||||
*
|
||||
* After finish of all selection tests, wrap up and go home.
|
||||
*
|
||||
*/
|
||||
function finishTests() {
|
||||
Messaging.sendRequest({
|
||||
type: TYPE_NAME,
|
||||
result: true,
|
||||
msg: "Done!",
|
||||
done: true
|
||||
});
|
||||
}
|
||||
|
|
@ -4,8 +4,12 @@
|
|||
<meta name="viewport" content="initial-scale=1.0"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="application/javascript" src="SelectionUtils.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
// Name of this test.
|
||||
const TYPE_NAME = "Robocop:testInputSelections";
|
||||
|
||||
// Used to create handle movement events for SelectionHandler.
|
||||
const ANCHOR = "ANCHOR";
|
||||
const FOCUS = "FOCUS";
|
||||
|
@ -22,11 +26,6 @@ const LTR_INPUT_TEXT_VALUE = "This input text is one character short of it's max
|
|||
const RTL_INPUT_TEXT_VALUE = "טקסט קלט זה קצר תו אחד של זה גדול.";
|
||||
|
||||
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import('resource://gre/modules/Geometry.jsm');
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* Start of all text selection tests, check initialization state.
|
||||
|
@ -418,123 +417,6 @@ function testRTL_dragAnchorHandleToSelf() {
|
|||
]);
|
||||
}
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* After finish of all selection tests, wrap up and go home.
|
||||
*
|
||||
*/
|
||||
function finishTests() {
|
||||
Messaging.sendRequest({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: true,
|
||||
msg: "Done!",
|
||||
done: true
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================== Utility functions ======================
|
||||
*
|
||||
* Common functions available to all tests.
|
||||
*
|
||||
*/
|
||||
function getSelectionHandler() {
|
||||
return (!this._selectionHandler) ?
|
||||
this._selectionHandler = Services.wm.getMostRecentWindow("navigator:browser").SelectionHandler :
|
||||
this._selectionHandler;
|
||||
}
|
||||
|
||||
function todo(result, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
todo: result,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function ok(result, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: result,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function is(one, two, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: one === two,
|
||||
msg: msg + " : " + one + " === " + two
|
||||
});
|
||||
}
|
||||
|
||||
function isNot(one, two, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: one !== two,
|
||||
msg: msg + " : " + one + " !== " + two
|
||||
});
|
||||
}
|
||||
|
||||
function lessThan(n1, n2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: n1 < n2,
|
||||
msg: msg + " : " + n1 + " < " + n2
|
||||
});
|
||||
}
|
||||
|
||||
function greaterThan(n1, n2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: n1 > n2,
|
||||
msg: msg + " : " + n1 + " > " + n2
|
||||
});
|
||||
}
|
||||
|
||||
// Use fuzzy logic to compare screen coords.
|
||||
function truncPoint(point) {
|
||||
return new Point(Math.trunc(point.x), Math.trunc(point.y));
|
||||
}
|
||||
|
||||
function pointEquals(p1, p2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: truncPoint(p1).equals(truncPoint(p2)),
|
||||
msg: msg + " : " + p1.toString() + " == " + p2.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function pointNotEquals(p1, p2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: !truncPoint(p1).equals(truncPoint(p2)),
|
||||
msg: msg + " : " + p1.toString() + " == " + p2.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function selectionExists(selection, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: !truncPoint(selection.anchorPt).equals(truncPoint(selection.focusPt)),
|
||||
msg: msg + " : anchor:" + selection.anchorPt.toString() +
|
||||
" focus:" + selection.focusPt.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function selectionEquals(s1, s2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testInputSelections",
|
||||
result: truncPoint(s1.anchorPt).equals(truncPoint(s2.anchorPt)) &&
|
||||
truncPoint(s1.focusPt).equals(truncPoint(s2.focusPt)),
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* Page definition for all tests.
|
||||
*
|
||||
*/
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
<meta name="viewport" content="initial-scale=1.0"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="application/javascript" src="SelectionUtils.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
// Name of this test.
|
||||
const TYPE_NAME = "Robocop:testSelectionHandler";
|
||||
|
||||
const DIV_POINT_TEXT = "Under";
|
||||
const INPUT_TEXT = "Text for select all in an <input>";
|
||||
const TEXTAREA_TEXT = "Text for select all in a <textarea>";
|
||||
const READONLY_INPUT_TEXT = "readOnly text";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* Start of all text selection tests, check initialization state.
|
||||
|
@ -348,53 +348,6 @@ function testAttachCaretFail() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* After finish of all selection tests, wrap up and go home.
|
||||
*
|
||||
*/
|
||||
function finishTests() {
|
||||
Messaging.sendRequest({
|
||||
type: "Robocop:testSelectionHandler",
|
||||
result: true,
|
||||
msg: "Done!",
|
||||
done: true
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================== Utility functions ======================
|
||||
*
|
||||
* Common functions available to all tests.
|
||||
*
|
||||
*/
|
||||
function getSelectionHandler() {
|
||||
return (!this._selectionHandler) ?
|
||||
this._selectionHandler = Services.wm.getMostRecentWindow("navigator:browser").SelectionHandler :
|
||||
this._selectionHandler;
|
||||
}
|
||||
|
||||
function ok(one, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testSelectionHandler",
|
||||
result: one,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function is(one, two, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testSelectionHandler",
|
||||
result: one === two,
|
||||
msg: msg + " : " + one + " === " + two
|
||||
});
|
||||
}
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* Page definition for all tests.
|
||||
*
|
||||
*/
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -4,8 +4,12 @@
|
|||
<meta name="viewport" content="initial-scale=1.0"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="application/javascript" src="SelectionUtils.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
// Name of this test.
|
||||
const TYPE_NAME = "Robocop:testTextareaSelections";
|
||||
|
||||
// Used to create handle movement events for SelectionHandler.
|
||||
const ANCHOR = "ANCHOR";
|
||||
const FOCUS = "FOCUS";
|
||||
|
@ -18,11 +22,6 @@ const EST_SEL_TEXT_BOUND_CHARS = 5;
|
|||
const EST_SEL_LINE_CHG_PTS = 10;
|
||||
|
||||
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import('resource://gre/modules/Geometry.jsm');
|
||||
|
||||
// Distance between text selection lines. Reality tested, and also
|
||||
// Used to perform multi-line selection selections.
|
||||
let selectionLineHeight = 0;
|
||||
|
@ -731,106 +730,6 @@ function testRTL_moveAnchorHandleDown() {
|
|||
]);
|
||||
}
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* After finish of all selection tests, wrap up and go home.
|
||||
*
|
||||
*/
|
||||
function finishTests() {
|
||||
Messaging.sendRequest({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: true,
|
||||
msg: "Done!",
|
||||
done: true
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================== Utility functions ======================
|
||||
*
|
||||
* Common functions available to all tests.
|
||||
*
|
||||
*/
|
||||
function getSelectionHandler() {
|
||||
return (!this._selectionHandler) ?
|
||||
this._selectionHandler = Services.wm.getMostRecentWindow("navigator:browser").SelectionHandler :
|
||||
this._selectionHandler;
|
||||
}
|
||||
|
||||
function todo(result, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
todo: result,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function ok(result, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: result,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function is(one, two, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: one === two,
|
||||
msg: msg + " : " + one + " === " + two
|
||||
});
|
||||
}
|
||||
|
||||
function lessThan(n1, n2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: n1 < n2,
|
||||
msg: msg + " : " + n1 + " < " + n2
|
||||
});
|
||||
}
|
||||
|
||||
function greaterThan(n1, n2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: n1 > n2,
|
||||
msg: msg + " : " + n1 + " > " + n2
|
||||
});
|
||||
}
|
||||
|
||||
// Use fuzzy logic to compare screen coords.
|
||||
function truncPoint(point) {
|
||||
return new Point(Math.trunc(point.x), Math.trunc(point.y));
|
||||
}
|
||||
|
||||
function pointEquals(p1, p2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: truncPoint(p1).equals(truncPoint(p2)),
|
||||
msg: msg + " : " + p1.toString() + " == " + p2.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function pointNotEquals(p1, p2, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: !truncPoint(p1).equals(truncPoint(p2)),
|
||||
msg: msg + " : " + p1.toString() + " == " + p2.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function selectionExists(selection, msg) {
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testTextareaSelections",
|
||||
result: !truncPoint(selection.anchorPt).equals(truncPoint(selection.focusPt)),
|
||||
msg: msg + " : anchor:" + selection.anchorPt.toString() +
|
||||
" focus:" + selection.focusPt.toString()
|
||||
});
|
||||
}
|
||||
|
||||
/* =================================================================================
|
||||
*
|
||||
* Page definition for all tests.
|
||||
*
|
||||
*/
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче