зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1648944 - Part 2: Fire selectionchange at document from text controls r=masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D86701
This commit is contained in:
Родитель
b09a40408c
Коммит
36a55d0f1c
|
@ -146,8 +146,9 @@ void SelectionChangeEventDispatcher::OnSelectionChange(Document* aDoc,
|
|||
nsCOMPtr<nsINode> target = textControl ? textControl : aDoc;
|
||||
|
||||
if (target) {
|
||||
CanBubble canBubble = textControl ? CanBubble::eYes : CanBubble::eNo;
|
||||
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(target, eSelectionChange, CanBubble::eNo);
|
||||
new AsyncEventDispatcher(target, eSelectionChange, canBubble);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2106,7 +2106,7 @@ void TextControlState::SetSelectionRange(
|
|||
if (IsSelectionCached() &&
|
||||
StaticPrefs::dom_select_events_textcontrols_selectionchange_enabled()) {
|
||||
asyncDispatcher = new AsyncEventDispatcher(
|
||||
mTextCtrlElement, eSelectionChange, CanBubble::eNo);
|
||||
mTextCtrlElement, eSelectionChange, CanBubble::eYes);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,13 @@
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
*/
|
||||
function isProperSelectionChangeTarget(node) {
|
||||
return node === document || node === input || node === textarea;
|
||||
}
|
||||
|
||||
// The main test
|
||||
parent.add_task(async function() {
|
||||
await spin();
|
||||
|
@ -70,8 +77,8 @@
|
|||
}
|
||||
});
|
||||
document.addEventListener('selectionchange', function(aEvent) {
|
||||
is(aEvent.originalTarget, document,
|
||||
"The original target of selectionchange should be the document");
|
||||
ok(isProperSelectionChangeTarget(aEvent.target),
|
||||
"The target of selectionchange should be one of document, input, or textarea");
|
||||
console.log(selectionchange);
|
||||
selectionchange++;
|
||||
});
|
||||
|
@ -341,11 +348,11 @@
|
|||
await mouseAction(elt("input"), 50, "mousedown", 0, 0, 0, 0);
|
||||
|
||||
selectstartTarget = elt("input");
|
||||
await mouseAction(elt("input"), 100, "mousemove", 1, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 100, "mousemove", 1, 1, 1, 0);
|
||||
|
||||
// Moving it more shouldn't trigger a start (move back to empty)
|
||||
await mouseAction(elt("input"), 75, "mousemove", 0, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 50, "mousemove", 0, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 75, "mousemove", 0, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 50, "mousemove", 0, 1, 1, 0);
|
||||
|
||||
// Wiggling the mouse a little such that it doesn't select any
|
||||
// characters shouldn't trigger a selection
|
||||
|
@ -354,7 +361,7 @@
|
|||
// Moving the mouse again from an empty selection should trigger a
|
||||
// selectstart
|
||||
selectstartTarget = elt("input");
|
||||
await mouseAction(elt("input"), 25, "mousemove", 1, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 25, "mousemove", 1, 1, 1, 0);
|
||||
|
||||
// Releasing the mouse shouldn't do anything
|
||||
await mouseAction(elt("input"), 25, "mouseup", 0, 0, 0, 0);
|
||||
|
@ -365,17 +372,17 @@
|
|||
|
||||
// Clicking in an random location should move the selection, but
|
||||
// not perform a selectstart
|
||||
await mouseAction(elt("input"), 50, "click", 0, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 50, "click", 0, 1, 1, 0);
|
||||
|
||||
// Clicking there again should do nothing
|
||||
await mouseAction(elt("input"), 50, "click", 0, 0, 0, 0);
|
||||
|
||||
// Selecting a region, and canceling the selectstart should mean that the
|
||||
// selection remains collapsed
|
||||
await mouseAction(elt("input"), 75, "mousedown", 0, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 75, "mousedown", 0, 1, 1, 0);
|
||||
cancel = true;
|
||||
selectstartTarget = elt("input");
|
||||
await mouseAction(elt("input"), 100, "mousemove", 1, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 100, "mousemove", 1, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 100, "mouseup", 0, 0, 0, 0);
|
||||
|
||||
|
||||
|
@ -396,11 +403,11 @@
|
|||
await mouseAction(elt("textarea"), 50, "mousedown", 0, 0, 0, 0);
|
||||
|
||||
selectstartTarget = elt("textarea");
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", 1, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", 1, 1, 0, 1);
|
||||
|
||||
// Moving it more shouldn't trigger a start (move back to empty)
|
||||
await mouseAction(elt("textarea"), 75, "mousemove", 0, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 50, "mousemove", 0, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 75, "mousemove", 0, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 50, "mousemove", 0, 1, 0, 1);
|
||||
|
||||
// Wiggling the mouse a little such that it doesn't select any
|
||||
// characters shouldn't trigger a selection
|
||||
|
@ -409,7 +416,7 @@
|
|||
// Moving the mouse again from an empty selection should trigger a
|
||||
// selectstart
|
||||
selectstartTarget = elt("textarea");
|
||||
await mouseAction(elt("textarea"), 25, "mousemove", 1, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 25, "mousemove", 1, 1, 0, 1);
|
||||
|
||||
// Releasing the mouse shouldn't do anything
|
||||
await mouseAction(elt("textarea"), 25, "mouseup", 0, 0, 0, 0);
|
||||
|
@ -420,17 +427,17 @@
|
|||
|
||||
// Clicking in an random location should move the selection, but not perform a
|
||||
// selectstart
|
||||
await mouseAction(elt("textarea"), 50, "click", 0, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 50, "click", 0, 1, 0, 1);
|
||||
|
||||
// Clicking there again should do nothing
|
||||
await mouseAction(elt("textarea"), 50, "click", 0, 0, 0, 0);
|
||||
|
||||
// Selecting a region, and canceling the selectstart should mean that the
|
||||
// selection remains collapsed
|
||||
await mouseAction(elt("textarea"), 75, "mousedown", 0, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 75, "mousedown", 0, 1, 0, 1);
|
||||
cancel = true;
|
||||
selectstartTarget = elt("textarea");
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", 1, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", 1, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 100, "mouseup", 0, 0, 0, 0);
|
||||
|
||||
// Marking the input and textarea as display: none and then as visible again
|
||||
|
|
Загрузка…
Ссылка в новой задаче