Bug 1649217 - Part 4: Update caret move event tests to support isSelectionCollapsed. r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D81914
This commit is contained in:
Eitan Isaacson 2020-07-02 17:43:24 +00:00
Родитель 970939c823
Коммит 65ed33dc4e
4 изменённых файлов: 41 добавлений и 33 удалений

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

@ -1659,12 +1659,12 @@ function moveToLineEnd(aID, aCaretOffset) {
aID,
"VK_RIGHT",
{ metaKey: true },
new caretMoveChecker(aCaretOffset, aID)
new caretMoveChecker(aCaretOffset, true, aID)
);
} else {
this.__proto__ = new synthEndKey(
aID,
new caretMoveChecker(aCaretOffset, aID)
new caretMoveChecker(aCaretOffset, true, aID)
);
}
@ -1679,7 +1679,7 @@ function moveToLineEnd(aID, aCaretOffset) {
function moveToPrevLineEnd(aID, aCaretOffset) {
this.__proto__ = new synthAction(
aID,
new caretMoveChecker(aCaretOffset, aID)
new caretMoveChecker(aCaretOffset, true, aID)
);
this.invoke = function moveToPrevLineEnd_invoke() {
@ -1706,12 +1706,12 @@ function moveToLineStart(aID, aCaretOffset) {
aID,
"VK_LEFT",
{ metaKey: true },
new caretMoveChecker(aCaretOffset, aID)
new caretMoveChecker(aCaretOffset, true, aID)
);
} else {
this.__proto__ = new synthHomeKey(
aID,
new caretMoveChecker(aCaretOffset, aID)
new caretMoveChecker(aCaretOffset, true, aID)
);
}
@ -1729,14 +1729,14 @@ function moveToTextStart(aID) {
aID,
"VK_UP",
{ metaKey: true },
new caretMoveChecker(0, aID)
new caretMoveChecker(0, true, aID)
);
} else {
this.__proto__ = new synthKey(
aID,
"VK_HOME",
{ ctrlKey: true },
new caretMoveChecker(0, aID)
new caretMoveChecker(0, true, aID)
);
}
@ -1792,7 +1792,7 @@ function moveCaretToDOMPoint(
}
};
this.eventSeq = [new caretMoveChecker(aExpectedOffset, this.target)];
this.eventSeq = [new caretMoveChecker(aExpectedOffset, true, this.target)];
if (this.focus) {
this.eventSeq.push(new asyncInvokerChecker(EVENT_FOCUS, this.focus));
@ -1815,7 +1815,7 @@ function setCaretOffset(aID, aOffset, aFocusTargetID) {
return "Set caretOffset on " + prettyName(aID) + " at " + this.offset;
};
this.eventSeq = [new caretMoveChecker(this.offset, this.target)];
this.eventSeq = [new caretMoveChecker(this.offset, true, this.target)];
if (this.focus) {
this.eventSeq.push(new asyncInvokerChecker(EVENT_FOCUS, this.focus));
@ -2013,6 +2013,7 @@ function textChangeChecker(
*/
function caretMoveChecker(
aCaretOffset,
aIsSelectionCollapsed,
aTargetOrFunc,
aTargetFuncArg,
aIsAsync
@ -2025,17 +2026,24 @@ function caretMoveChecker(
);
this.check = function caretMoveChecker_check(aEvent) {
let evt = aEvent.QueryInterface(nsIAccessibleCaretMoveEvent);
is(
aEvent.QueryInterface(nsIAccessibleCaretMoveEvent).caretOffset,
evt.caretOffset,
aCaretOffset,
"Wrong caret offset for " + prettyName(aEvent.accessible)
);
is(
evt.isSelectionCollapsed,
aIsSelectionCollapsed,
"wrong collapsed value for " + prettyName(aEvent.accessible)
);
};
}
function asyncCaretMoveChecker(aCaretOffset, aTargetOrFunc, aTargetFuncArg) {
this.__proto__ = new caretMoveChecker(
aCaretOffset,
true, // Caret is collapsed
aTargetOrFunc,
aTargetFuncArg,
true

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

@ -18,8 +18,8 @@
/**
* Click checker.
*/
function clickChecker(aCaretOffset, aID, aExtraNodeOrID, aExtraCaretOffset) {
this.__proto__ = new caretMoveChecker(aCaretOffset, aID);
function clickChecker(aCaretOffset, aIsSelectionCollapsed, aID, aExtraNodeOrID, aExtraCaretOffset) {
this.__proto__ = new caretMoveChecker(aCaretOffset, aIsSelectionCollapsed, aID);
this.extraNode = getNode(aExtraNodeOrID);
@ -46,43 +46,43 @@
gQueue = new eventQueue();
var id = "textbox";
gQueue.push(new synthFocus(id, new caretMoveChecker(5, id)));
gQueue.push(new synthSelectAll(id, new caretMoveChecker(5, id)));
gQueue.push(new synthClick(id, new caretMoveChecker(0, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, id)));
gQueue.push(new synthFocus(id, new caretMoveChecker(5, true, id)));
gQueue.push(new synthSelectAll(id, new caretMoveChecker(5, false, id)));
gQueue.push(new synthClick(id, new caretMoveChecker(0, true, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, true, id)));
if (!MAC) {
gQueue.push(new synthSelectAll(id, new caretMoveChecker(5, id)));
gQueue.push(new synthHomeKey(id, new caretMoveChecker(0, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, id)));
gQueue.push(new synthSelectAll(id, new caretMoveChecker(5, false, id)));
gQueue.push(new synthHomeKey(id, new caretMoveChecker(0, true, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, true, id)));
}
else {
todo(false, "Make these tests pass on OSX (bug 650294)");
}
id = "textarea";
gQueue.push(new synthClick(id, new caretMoveChecker(0, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, id)));
gQueue.push(new synthDownKey(id, new caretMoveChecker(12, id)));
gQueue.push(new synthClick(id, new caretMoveChecker(0, true, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, true, id)));
gQueue.push(new synthDownKey(id, new caretMoveChecker(12, true, id)));
id = "textarea_wrapped";
gQueue.push(new setCaretOffset(id, 4, id));
gQueue.push(new synthLeftKey(id, new caretMoveChecker(4, id)));
gQueue.push(new synthLeftKey(id, new caretMoveChecker(4, true, id)));
id = "p";
gQueue.push(new synthClick(id, new caretMoveChecker(0, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, id)));
gQueue.push(new synthDownKey(id, new caretMoveChecker(6, id)));
gQueue.push(new synthClick(id, new caretMoveChecker(0, true, id)));
gQueue.push(new synthRightKey(id, new caretMoveChecker(1, true, id)));
gQueue.push(new synthDownKey(id, new caretMoveChecker(6, true, id)));
id = "p1_in_div";
gQueue.push(new synthClick(id, new clickChecker(0, id, "p2_in_div", -1)));
gQueue.push(new synthClick(id, new clickChecker(0, true, id, "p2_in_div", -1)));
id = "p";
gQueue.push(new synthShiftTab(id, new caretMoveChecker(0, id)));
gQueue.push(new synthShiftTab(id, new caretMoveChecker(0, true, id)));
id = "textarea";
gQueue.push(new synthShiftTab(id, new caretMoveChecker(12, id)));
gQueue.push(new synthShiftTab(id, new caretMoveChecker(12, true, id)));
id = "p";
gQueue.push(new synthTab(id, new caretMoveChecker(0, id)));
gQueue.push(new synthTab(id, new caretMoveChecker(0, true, id)));
// Set caret after a child of span element, i.e. after 'text' text.
gQueue.push(new moveCaretToDOMPoint("test1", getNode("test1_span"), 1,

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

@ -24,7 +24,7 @@
function getOnclickSeq(aID) {
return [
new caretMoveChecker(0, aID),
new caretMoveChecker(0, true, aID),
new unexpectedInvokerChecker(EVENT_TEXT_SELECTION_CHANGED, aID),
];
}
@ -43,7 +43,7 @@
{ shiftKey: true }));
gQueue.push(new synthLeftKey("ta1",
[new textSelectionChecker("ta1", 0, 0, "ta1", 0, "ta1", 0),
new caretMoveChecker(0, "ta1")]));
new caretMoveChecker(0, true, "ta1")]));
gQueue.invoke(); // Will call SimpleTest.finish();
}

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

@ -318,7 +318,7 @@
function tmpl_moveTo(aID, aInvokerFunc, aWholeText, aCharIter) {
this.offset = aCharIter.offset;
var checker = new caretMoveChecker(this.offset, aID);
var checker = new caretMoveChecker(this.offset, true, aID);
this.__proto__ = new (aInvokerFunc)(aID, checker);
this.finalCheck = function genericMoveTo_finalCheck() {