mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-06-06 00:19:08 +00:00
745 lines
33 KiB
HTML
745 lines
33 KiB
HTML
<html>
|
|
<head>
|
|
<title>Automated RTL/LTR Text Selection tests for Textareas</title>
|
|
<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";
|
|
|
|
// Used to specifiy midpoint selection text left/right of center.
|
|
const EST_SEL_TEXT_BOUND_CHARS = 5;
|
|
|
|
// Used to ensure calculated coords for handle movement events get us
|
|
// "into" the next/prev line vertically.
|
|
const EST_SEL_LINE_CHG_PTS = 10;
|
|
|
|
|
|
// Distance between text selection lines. Reality tested, and also
|
|
// Used to perform multi-line selection selections.
|
|
let selectionLineHeight = 0;
|
|
|
|
/* =================================================================================
|
|
*
|
|
* Start of all text selection tests, check initialization state.
|
|
*/
|
|
function startTests() {
|
|
testLTR_selectionPoints().
|
|
then(testRTL_selectionPoints).
|
|
|
|
then(test_selectionLineHeight).
|
|
|
|
then(testLTR_moveFocusHandleDown).
|
|
then(testLTR_moveFocusHandleUp).
|
|
then(testLTR_moveAnchorHandleUp).
|
|
then(testLTR_moveAnchorHandleDown).
|
|
|
|
then(testRTL_moveFocusHandleDown).
|
|
then(testRTL_moveFocusHandleUp).
|
|
then(testRTL_moveAnchorHandleUp).
|
|
then(testRTL_moveAnchorHandleDown).
|
|
|
|
then(finishTests, function(err) {
|
|
ok(false, "Error in selection test " + err);
|
|
finishTests();
|
|
});
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* LTR Textarea test will create a single line selection in the middle of the element
|
|
* and ensure that the anchor point is to the left of the focus point.
|
|
*/
|
|
function testLTR_selectionPoints() {
|
|
// Select entire LTRTextArea.
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("LTRTextarea");
|
|
sh.startSelection(element);
|
|
|
|
return Promise.all([
|
|
ok(sh.isSelectionActive(),
|
|
"testLTR_selectionPoints starts, selection should be active."),
|
|
|
|
]).then(function() {
|
|
// setSelectionRange() (in editable elements), gets us a single-line selection of
|
|
// midpoint character +- EST_SEL_TEXT_BOUND_CHARS chars on either side.
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Grab values that are cleared by closing selection.
|
|
let selection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
let midpointSelText = sh._getSelectedText();
|
|
|
|
// Close selection and complete test.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
selectionExists(selection, "LTR Selection existed at points"),
|
|
|
|
is(midpointSelText, " plasma of", "LTR Selection should match expected text"),
|
|
is(selection.anchorPt.y, selection.focusPt.y,
|
|
"LTR Selection anchorPt should match focusPt vertically"),
|
|
lessThan(selection.anchorPt.x, selection.focusPt.x,
|
|
"LTR Selection anchorPt should be the left of focusPt"),
|
|
ok(!sh.isSelectionActive(),
|
|
"testLTR_selectionPoints finishes, selection should not be active."),
|
|
]);
|
|
});
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* RTL Textarea test will create a single line selection in the middle of the element
|
|
* and ensure that the anchor point is to the right of the focus point.
|
|
*/
|
|
function testRTL_selectionPoints() {
|
|
// Select entire RTLTextArea.
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("RTLTextarea");
|
|
sh.startSelection(element);
|
|
|
|
return Promise.all([
|
|
ok(sh.isSelectionActive(),
|
|
"testRTL_selectionPoints starts, selection should be active."),
|
|
|
|
]).then(function() {
|
|
// setSelectionRange() (in editable elements), gets us a single-line selection of
|
|
// midpoint character +- EST_SEL_TEXT_BOUND_CHARS chars on either side.
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Grab values that are cleared by closing selection.
|
|
let selection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
let midpointSelText = sh._getSelectedText();
|
|
|
|
// Close selection and complete test.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
selectionExists(selection, "RTL Selection existed at points"),
|
|
|
|
is(midpointSelText, "ל גם את הב", "RTL Selection should match expected text"),
|
|
is(selection.anchorPt.y, selection.focusPt.y,
|
|
"RTL Selection anchorPt should match focusPt vertically"),
|
|
greaterThan(selection.anchorPt.x, selection.focusPt.x,
|
|
"RTL Selection anchorPt should be to the right of focusPt"),
|
|
ok(!sh.isSelectionActive(),
|
|
"testRTL_selectionPoints finishes, selection should not be active."),
|
|
]);
|
|
});
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* Textarea test will create (a) a single-line selection in the middle of the element,
|
|
* move the focus handle down a line creating (b) a two-line selection, and then
|
|
* ensure that the vertical distance between the bottom of (a) and (b) is > 0.
|
|
*
|
|
* The result is used later to ensure more-precise handle up/down movements.
|
|
*/
|
|
function test_selectionLineHeight() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("LTRTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection focus to next lower line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : FOCUS,
|
|
x : initialSelection.focusPt.x,
|
|
y : initialSelection.focusPt.y + EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : FOCUS })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Note selection line height for reality test,
|
|
// and later handle movement calculations.
|
|
selectionLineHeight = changedSelection.focusPt.y - initialSelection.focusPt.y;
|
|
|
|
return Promise.all([
|
|
ok(sh.isSelectionActive(),
|
|
"test_selectionLineHeight starts, selection should be active."),
|
|
|
|
]).then(function() {
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
greaterThan(selectionLineHeight, 0, "Distance from one line to another " +
|
|
"in a multi-line selection is greater than 0."),
|
|
|
|
ok(!sh.isSelectionActive(),
|
|
"test_selectionLineHeight finishes, selection should not be active."),
|
|
]);
|
|
});
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* LTR Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during focus handle down movements.
|
|
*/
|
|
function testLTR_moveFocusHandleDown() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("LTRTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection focus to next lower line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : FOCUS,
|
|
x : initialSelection.focusPt.x,
|
|
y : initialSelection.focusPt.y + EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : FOCUS })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testLTR_moveFocusHandleDown - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "LTR Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"LTR Initial selection anchorPt.y should match focusPt.y"),
|
|
lessThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"LTR Initial selection anchorPt.x should be less than (left of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "LTR Changed selection existed at points"),
|
|
pointEquals(changedSelection.anchorPt, initialSelection.anchorPt,
|
|
"LTR Changed selection focus handle moving down " +
|
|
"should not change anchor handle."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"LTR Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
greaterThan(changedSelection.focusPt.y, initialSelection.focusPt.y,
|
|
"LTR Changed selection focusPt.y " +
|
|
"should be greater than (below) Initial selection focusPt.y"),
|
|
]);
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* LTR Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during focus handle up movements.
|
|
*/
|
|
|
|
function testLTR_moveFocusHandleUp() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("LTRTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection focus to next upper line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : FOCUS,
|
|
x : initialSelection.focusPt.x,
|
|
y : initialSelection.focusPt.y - selectionLineHeight - EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : FOCUS })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testLTR_moveFocusHandleUp - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "LTR Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"LTR Initial selection anchorPt.y should match focusPt.y"),
|
|
lessThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"LTR Initial selection anchorPt.x should be less than (left of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "LTR Changed selection existed at points"),
|
|
pointEquals(changedSelection.focusPt, initialSelection.anchorPt,
|
|
"LTR Reversed Changed selection focus handle moving up " +
|
|
"becomes new anchor handle, " +
|
|
"new focus handle is initial anchor handle."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"LTR Reversed Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
is(changedSelection.focusPt.y, initialSelection.focusPt.y,
|
|
"LTR Reversed Changed selection focusPt.y " +
|
|
"should be equal-to Initial selection focusPt.y"),
|
|
lessThan(changedSelection.anchorPt.y, initialSelection.anchorPt.y,
|
|
"LTR Reversed Changed selection anchorPt.y " +
|
|
"should be less than (above) Initial selection anchorPt.y"),
|
|
]);
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* LTR Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during anchor handle up movements.
|
|
*/
|
|
function testLTR_moveAnchorHandleUp() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("LTRTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection anchor to next upper line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : ANCHOR,
|
|
x : initialSelection.anchorPt.x,
|
|
y : initialSelection.anchorPt.y - selectionLineHeight - EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : ANCHOR })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testLTR_moveAnchorHandleUp - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "LTR Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"LTR Initial selection anchorPt.y should match focusPt.y"),
|
|
lessThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"LTR Initial selection anchorPt.x should be less than (left of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "LTR Changed selection existed at points"),
|
|
pointEquals(changedSelection.focusPt, initialSelection.focusPt,
|
|
"LTR Changed selection anchor handle moving up " +
|
|
"should not change focus handle."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"LTR Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
lessThan(changedSelection.anchorPt.y, initialSelection.anchorPt.y,
|
|
"LTR Changed selection anchorPt.y " +
|
|
"should be less than (above) Initial selection anchorPt.y"),
|
|
]);
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* LTR Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during anchor handle down movements.
|
|
*/
|
|
function testLTR_moveAnchorHandleDown() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("LTRTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection anchor to next lower line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : ANCHOR,
|
|
x : initialSelection.anchorPt.x,
|
|
y : initialSelection.anchorPt.y + EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : ANCHOR })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testLTR_moveAnchorHandleDown - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "LTR Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"LTR Initial selection anchorPt.y should match focusPt.y"),
|
|
lessThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"LTR Initial selection anchorPt.x should be less than (left of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "LTR Changed selection existed at points"),
|
|
pointEquals(changedSelection.anchorPt, initialSelection.focusPt,
|
|
"LTR Reversed Changed selection anchor handle moving down " +
|
|
"becomes new focus handle, " +
|
|
"new anchor handle is initial focus handle."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"LTR Reversed Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
is(changedSelection.anchorPt.y, initialSelection.anchorPt.y,
|
|
"LTR Reversed Changed selection anchorPt.y " +
|
|
"should be equal to Initial selection anchorPt.y"),
|
|
greaterThan(changedSelection.focusPt.y, initialSelection.focusPt.y,
|
|
"LTR Reversed Changed selection focusPt.y " +
|
|
"should be greater than (below) Initial selection focusPt.y"),
|
|
]);
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* RTL Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during focus handle down movements.
|
|
*/
|
|
function testRTL_moveFocusHandleDown() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("RTLTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection focus to next lower line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : FOCUS,
|
|
x : initialSelection.focusPt.x,
|
|
y : initialSelection.focusPt.y + EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : FOCUS })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testRTL_moveFocusHandleDown - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "RTL Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"RTL Initial selection anchorPt.y should match focusPt.y"),
|
|
greaterThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"RTL Initial selection anchorPt.x should be greater than (right of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "RTL Changed selection existed at points"),
|
|
pointEquals(changedSelection.anchorPt, initialSelection.anchorPt,
|
|
"RTL Changed selection focus handle moving down " +
|
|
"should not change anchor handle position."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"RTL Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
greaterThan(changedSelection.focusPt.y, initialSelection.focusPt.y,
|
|
"RTL Changed selection focusPt.y " +
|
|
"should be greater than (below) Initial selection focusPt.y"),
|
|
]);
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* RTL Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during focus handle up movements.
|
|
*/
|
|
function testRTL_moveFocusHandleUp() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("RTLTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection focus to next upper line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : FOCUS,
|
|
x : initialSelection.focusPt.x,
|
|
y : initialSelection.focusPt.y - selectionLineHeight - EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : FOCUS })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testRTL_moveFocusHandleUp - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "RTL Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"RTL Initial selection anchorPt.y should match focusPt.y"),
|
|
greaterThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"RTL Initial selection anchorPt.x should be greater than (right of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "RTL Changed selection existed at points"),
|
|
pointEquals(changedSelection.focusPt, initialSelection.anchorPt,
|
|
"RTL Reversed Changed selection focus handle moving up " +
|
|
"becomes new anchor handle, " +
|
|
"new focus handle is initial anchor handle."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"RTL Reversed Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
is(changedSelection.focusPt.y, initialSelection.focusPt.y,
|
|
"RTL Reversed Changed selection focusPt.y " +
|
|
"should be equal to Initial selection focusPt.y"),
|
|
lessThan(changedSelection.anchorPt.y, initialSelection.anchorPt.y,
|
|
"RTL Reversed Changed selection anchorPt.y " +
|
|
"should be less than (above) Initial selection anchorPt.y"),
|
|
]);
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* RTL Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during anchor handle up movements.
|
|
*/
|
|
function testRTL_moveAnchorHandleUp() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("RTLTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection anchor to next upper line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : ANCHOR,
|
|
x : initialSelection.anchorPt.x,
|
|
y : initialSelection.anchorPt.y - selectionLineHeight - EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : ANCHOR })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testRTL_moveAnchorHandleUp - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "RTL Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"RTL Initial selection anchorPt.y should match focusPt.y"),
|
|
greaterThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"RTL Initial selection anchorPt.x should be greater than (right of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "RTL Changed selection existed at points"),
|
|
pointEquals(changedSelection.focusPt, initialSelection.focusPt,
|
|
"RTL Changed selection anchor handle moving up " +
|
|
"should not change focus handle position."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"RTL Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
lessThan(changedSelection.anchorPt.y, initialSelection.anchorPt.y,
|
|
"RTL Changed selection anchorPt.y " +
|
|
"should be less than (above) Initial selection anchorPt.y"),
|
|
]);
|
|
}
|
|
|
|
/* =================================================================================
|
|
*
|
|
* RTL Textarea test will create a single-line selection in the middle of the element
|
|
* and ensure that handle reversals are detected as expected.
|
|
*
|
|
* This tests what happens during anchor handle down movements.
|
|
*/
|
|
function testRTL_moveAnchorHandleDown() {
|
|
let sh = getSelectionHandler();
|
|
let element = document.getElementById("RTLTextarea");
|
|
let initialSelection = null;
|
|
let changedSelection = null;
|
|
|
|
// Select entire textarea, refine selection to midpoint string.
|
|
sh.startSelection(element);
|
|
let midpointSelCharOffset = (element.selectionStart + element.selectionEnd) / 2;
|
|
element.setSelectionRange(midpointSelCharOffset - EST_SEL_TEXT_BOUND_CHARS,
|
|
midpointSelCharOffset + EST_SEL_TEXT_BOUND_CHARS);
|
|
|
|
// Note initial selection points.
|
|
initialSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Force selection anchor to next lower line (estimate distance required).
|
|
Services.obs.notifyObservers(null, "TextSelection:Move",
|
|
JSON.stringify({ handleType : ANCHOR,
|
|
x : initialSelection.anchorPt.x,
|
|
y : initialSelection.anchorPt.y + EST_SEL_LINE_CHG_PTS
|
|
})
|
|
);
|
|
Services.obs.notifyObservers(null, "TextSelection:Position",
|
|
JSON.stringify({ handleType : ANCHOR })
|
|
);
|
|
|
|
// Note changed selection points after handle movement.
|
|
changedSelection = { anchorPt : new Point(sh._cache.anchorPt.x, sh._cache.anchorPt.y),
|
|
focusPt : new Point(sh._cache.focusPt.x, sh._cache.focusPt.y) };
|
|
|
|
// Complete test, and report.
|
|
Services.obs.notifyObservers(null, "TextSelection:End", {});
|
|
|
|
return Promise.all([
|
|
ok(true, "testRTL_moveAnchorHandleDown - Test Starts."),
|
|
|
|
selectionExists(initialSelection, "RTL Initial selection existed at points"),
|
|
is(initialSelection.anchorPt.y, initialSelection.focusPt.y,
|
|
"RTL Initial selection anchorPt.y should match focusPt.y"),
|
|
greaterThan(initialSelection.anchorPt.x, initialSelection.focusPt.x,
|
|
"RTL Initial selection anchorPt.x should be greater than (right of) focusPt.x"),
|
|
|
|
selectionExists(changedSelection, "RTL Changed selection existed at points"),
|
|
pointEquals(changedSelection.anchorPt, initialSelection.focusPt,
|
|
"RTL Reversed Changed selection anchor handle moving down " +
|
|
"becomes new focus handle, " +
|
|
"new anchor handle is initial focus handle."),
|
|
greaterThan(changedSelection.focusPt.y, changedSelection.anchorPt.y,
|
|
"RTL Reversed Changed selection focusPt.y " +
|
|
"should be greater than (below) changed anchorPt.y"),
|
|
|
|
is(changedSelection.anchorPt.y, initialSelection.anchorPt.y,
|
|
"RTL Reversed Changed selection anchorPt.y " +
|
|
"should be equal to Initial selection anchorPt.y"),
|
|
greaterThan(changedSelection.focusPt.y, initialSelection.focusPt.y,
|
|
"RTL Reversed Changed selection focusPt.y " +
|
|
"should be greater than (below) Initial selection focusPt.y"),
|
|
]);
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
|
|
<body onload="startTests();">
|
|
<textarea id="LTRTextarea" style="direction: ltr;" rows="10" cols="40"
|
|
readonly="true">Under sufficiently extreme conditions, quarks may become deconfined and exist as free particles. In the course of asymptotic freedom, the strong interaction becomes weaker at higher temperatures. Eventually, color confinement would be lost and an extremely hot plasma of freely moving quarks and gluons would be formed. This theoretical phase of matter is called quark-gluon plasma.[81] The exact conditions needed to give rise to this state are unknown and have been the subject of a great deal of speculation and experimentation.</textarea>
|
|
|
|
<textarea id="RTLTextarea" style="direction: rtl;" rows="10" cols="40"
|
|
readonly="true">טטיאנה קוזמינה, שהייתה 18, תלמיד תיכון בעפולה, עלה לישראל לפני כשנים עם האמא שלה, שהיה נשואה לאזרח ישראלי, כאשר אביה הביולוגי חתם על מסמך המאשר את המהלך שלה לישראל. האמא שלה היא בתהליך של התאזרחות חשב שזה כולל גם את הבת שלה, אבל ברגע שהיא הבינה כבר לפני כמה חודשים שהחברה המאוחדת לא נכללה בו, דחה את הבקשה לעבד גם לבת שלה. ואז הם קיבלו את הגור.וחד-קרן הגיעה, אבל הם לא הצליחו למצוא את קשת אז כולם אכלו ספגטי וכנפיים בופל חמים.</textarea>
|
|
</body>
|
|
|
|
</html>
|