Backed out 5 changesets (bug 1648944) for causing wpt failures in idlharness.window.html.
CLOSED TREE Backed out changeset 598789cabb9f (bug 1648944) Backed out changeset f464507bef57 (bug 1648944) Backed out changeset fb2b9ceb7c69 (bug 1648944) Backed out changeset a73cfada74cf (bug 1648944) Backed out changeset 3f41877ffd14 (bug 1648944)
This commit is contained in:
@@ -884,9 +884,7 @@ nsresult Selection::AddRangesForUserSelectableNodes(
|
||||
// pref, disabled by default.
|
||||
// See https://github.com/w3c/selection-api/issues/53.
|
||||
const bool executeDefaultAction = MaybeDispatchSelectstartEvent(
|
||||
*aRange,
|
||||
StaticPrefs::dom_select_events_textcontrols_selectstart_enabled(),
|
||||
doc);
|
||||
*aRange, StaticPrefs::dom_select_events_textcontrols_enabled(), doc);
|
||||
|
||||
if (!executeDefaultAction) {
|
||||
return NS_OK;
|
||||
|
||||
@@ -138,17 +138,15 @@ void SelectionChangeEventDispatcher::OnSelectionChange(Document* aDoc,
|
||||
// controls, so for now we only support doing that under a pref, disabled by
|
||||
// default.
|
||||
// See https://github.com/w3c/selection-api/issues/53.
|
||||
if (textControl &&
|
||||
!StaticPrefs::dom_select_events_textcontrols_selectionchange_enabled()) {
|
||||
if (textControl && !StaticPrefs::dom_select_events_textcontrols_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> target = textControl ? textControl : aDoc;
|
||||
|
||||
if (target) {
|
||||
CanBubble canBubble = textControl ? CanBubble::eYes : CanBubble::eNo;
|
||||
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(target, eSelectionChange, canBubble);
|
||||
new AsyncEventDispatcher(target, eSelectionChange, CanBubble::eNo);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ TOUCH_EVENT(touchcancel, eTouchCancel, EventNameType_All, eTouchEventClass)
|
||||
|
||||
DOCUMENT_ONLY_EVENT(readystatechange, eReadyStateChange, EventNameType_HTMLXUL,
|
||||
eBasicEventClass)
|
||||
EVENT(selectionchange, eSelectionChange, EventNameType_HTMLXUL,
|
||||
DOCUMENT_ONLY_EVENT(selectionchange, eSelectionChange, EventNameType_HTMLXUL,
|
||||
eBasicEventClass)
|
||||
DOCUMENT_ONLY_EVENT(visibilitychange, eVisibilityChange, EventNameType_HTMLXUL,
|
||||
eBasicEventClass)
|
||||
|
||||
@@ -2104,9 +2104,9 @@ void TextControlState::SetSelectionRange(
|
||||
// XXX(krosylight): Shouldn't it fire before select event?
|
||||
// Currently Gecko and Blink both fire selectionchange after select.
|
||||
if (IsSelectionCached() &&
|
||||
StaticPrefs::dom_select_events_textcontrols_selectionchange_enabled()) {
|
||||
StaticPrefs::dom_select_events_textcontrols_enabled()) {
|
||||
asyncDispatcher = new AsyncEventDispatcher(
|
||||
mTextCtrlElement, eSelectionChange, CanBubble::eYes);
|
||||
mTextCtrlElement, eSelectionChange, CanBubble::eNo);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
*/
|
||||
function isProperSelectionChangeTarget(node) {
|
||||
return node === document || node === input || node === textarea;
|
||||
}
|
||||
|
||||
// The main test
|
||||
parent.add_task(async function() {
|
||||
await spin();
|
||||
@@ -53,18 +46,10 @@
|
||||
var cancel = false;
|
||||
var selectstartTarget = null;
|
||||
|
||||
async function UpdateSelectEventsOnTextControlsPref({ selectstart, selectionchange }) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
'set': [
|
||||
['dom.select_events.textcontrols.selectstart.enabled', !!selectstart],
|
||||
['dom.select_events.textcontrols.selectionchange.enabled', !!selectionchange]
|
||||
]
|
||||
});
|
||||
async function UpdateSelectEventsOntextControlsPref(aEnabled) {
|
||||
await SpecialPowers.pushPrefEnv({'set': [['dom.select_events.textcontrols.enabled', aEnabled]]});
|
||||
}
|
||||
await UpdateSelectEventsOnTextControlsPref({
|
||||
selectstart: false,
|
||||
selectionchange: false
|
||||
});
|
||||
await UpdateSelectEventsOntextControlsPref(false);
|
||||
|
||||
document.addEventListener('selectstart', function(aEvent) {
|
||||
console.log("originaltarget", aEvent.originalTarget, "new", selectstartTarget);
|
||||
@@ -80,8 +65,8 @@
|
||||
}
|
||||
});
|
||||
document.addEventListener('selectionchange', function(aEvent) {
|
||||
ok(isProperSelectionChangeTarget(aEvent.target),
|
||||
"The target of selectionchange should be one of document, input, or textarea");
|
||||
is(aEvent.originalTarget, document,
|
||||
"The original target of selectionchange should be the document");
|
||||
console.log(selectionchange);
|
||||
selectionchange++;
|
||||
});
|
||||
@@ -346,29 +331,25 @@
|
||||
// Releasing the mouse shouldn't do anything
|
||||
await mouseAction(elt("input"), 50, "mouseup", 0, 0, 0, 0);
|
||||
|
||||
for (const selectstart of [1, 0]) {
|
||||
await UpdateSelectEventsOnTextControlsPref({
|
||||
selectstart,
|
||||
selectionchange: true
|
||||
});
|
||||
await UpdateSelectEventsOntextControlsPref(true);
|
||||
|
||||
await mouseAction(elt("input"), 40, "mousedown", 0, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 50, "mousedown", 0, 0, 0, 0);
|
||||
|
||||
selectstartTarget = elt("input");
|
||||
await mouseAction(elt("input"), 100, "mousemove", selectstart, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 100, "mousemove", 1, 0, 1, 0);
|
||||
|
||||
// Moving it more shouldn't trigger a start (move back to empty)
|
||||
await mouseAction(elt("input"), 75, "mousemove", 0, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 40, "mousemove", 0, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 75, "mousemove", 0, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 50, "mousemove", 0, 0, 1, 0);
|
||||
|
||||
// Wiggling the mouse a little such that it doesn't select any
|
||||
// characters shouldn't trigger a selection
|
||||
await mouseAction(elt("input"), 40, "mousemove", 0, 0, 0, 0, 11);
|
||||
await mouseAction(elt("input"), 50, "mousemove", 0, 0, 0, 0, 11);
|
||||
|
||||
// Moving the mouse again from an empty selection should trigger a
|
||||
// selectstart
|
||||
selectstartTarget = elt("input");
|
||||
await mouseAction(elt("input"), 25, "mousemove", selectstart, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 25, "mousemove", 1, 0, 1, 0);
|
||||
|
||||
// Releasing the mouse shouldn't do anything
|
||||
await mouseAction(elt("input"), 25, "mouseup", 0, 0, 0, 0);
|
||||
@@ -379,24 +360,21 @@
|
||||
|
||||
// Clicking in an random location should move the selection, but
|
||||
// not perform a selectstart
|
||||
await mouseAction(elt("input"), 50, "click", 0, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 50, "click", 0, 0, 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, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 75, "mousedown", 0, 0, 1, 0);
|
||||
cancel = true;
|
||||
selectstartTarget = elt("input");
|
||||
await mouseAction(elt("input"), 100, "mousemove", selectstart, 1, 1, 0);
|
||||
await mouseAction(elt("input"), 100, "mousemove", 1, 0, 1, 0);
|
||||
await mouseAction(elt("input"), 100, "mouseup", 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
await UpdateSelectEventsOnTextControlsPref({
|
||||
selectstart: false,
|
||||
selectionchange: false
|
||||
});
|
||||
|
||||
await UpdateSelectEventsOntextControlsPref(false);
|
||||
|
||||
// Without the dom.select_events.textcontrols.enabled pref,
|
||||
// pressing the mouse shouldn't do anything.
|
||||
@@ -407,29 +385,26 @@
|
||||
// Releasing the mouse shouldn't do anything
|
||||
await mouseAction(elt("textarea"), 50, "mouseup", 0, 0, 0, 0);
|
||||
|
||||
for (const selectstart of [1, 0]) {
|
||||
await UpdateSelectEventsOnTextControlsPref({
|
||||
selectstart,
|
||||
selectionchange: true
|
||||
});
|
||||
await UpdateSelectEventsOntextControlsPref(true);
|
||||
|
||||
// Select a region
|
||||
await mouseAction(elt("textarea"), 40, "mousedown", 0, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 50, "mousedown", 0, 0, 0, 0);
|
||||
|
||||
selectstartTarget = elt("textarea");
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", selectstart, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", 1, 0, 0, 1);
|
||||
|
||||
// Moving it more shouldn't trigger a start (move back to empty)
|
||||
await mouseAction(elt("textarea"), 75, "mousemove", 0, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 40, "mousemove", 0, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 75, "mousemove", 0, 0, 0, 1);
|
||||
await mouseAction(elt("textarea"), 50, "mousemove", 0, 0, 0, 1);
|
||||
|
||||
// Wiggling the mouse a little such that it doesn't select any
|
||||
// characters shouldn't trigger a selection
|
||||
await mouseAction(elt("textarea"), 40, "mousemove", 0, 0, 0, 0, 11);
|
||||
await mouseAction(elt("textarea"), 50, "mousemove", 0, 0, 0, 0, 11);
|
||||
|
||||
// Moving the mouse again from an empty selection should trigger a
|
||||
// selectstart
|
||||
selectstartTarget = elt("textarea");
|
||||
await mouseAction(elt("textarea"), 25, "mousemove", selectstart, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 25, "mousemove", 1, 0, 0, 1);
|
||||
|
||||
// Releasing the mouse shouldn't do anything
|
||||
await mouseAction(elt("textarea"), 25, "mouseup", 0, 0, 0, 0);
|
||||
@@ -440,19 +415,18 @@
|
||||
|
||||
// Clicking in an random location should move the selection, but not perform a
|
||||
// selectstart
|
||||
await mouseAction(elt("textarea"), 50, "click", 0, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 50, "click", 0, 0, 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, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 75, "mousedown", 0, 0, 0, 1);
|
||||
cancel = true;
|
||||
selectstartTarget = elt("textarea");
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", selectstart, 1, 0, 1);
|
||||
await mouseAction(elt("textarea"), 100, "mousemove", 1, 0, 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
|
||||
// shouldn't trigger any changes, although the nodes will be re-framed
|
||||
|
||||
@@ -191,6 +191,8 @@ partial interface Document {
|
||||
attribute EventHandler onbeforescriptexecute;
|
||||
attribute EventHandler onafterscriptexecute;
|
||||
|
||||
attribute EventHandler onselectionchange;
|
||||
|
||||
/**
|
||||
* True if this document is synthetic : stand alone image, video, audio file,
|
||||
* etc.
|
||||
|
||||
@@ -93,7 +93,6 @@ interface mixin GlobalEventHandlers {
|
||||
attribute EventHandler onwaiting;
|
||||
|
||||
attribute EventHandler onselectstart;
|
||||
attribute EventHandler onselectionchange;
|
||||
|
||||
attribute EventHandler ontoggle;
|
||||
|
||||
|
||||
@@ -3096,12 +3096,7 @@
|
||||
mirror: always
|
||||
|
||||
# Whether or not selection events on text controls are enabled.
|
||||
- name: dom.select_events.textcontrols.selectionchange.enabled
|
||||
type: bool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
- name: dom.select_events.textcontrols.selectstart.enabled
|
||||
- name: dom.select_events.textcontrols.enabled
|
||||
type: bool
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
mirror: always
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Test selectionchange events bubbling from text controls</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<input id="input" width="200" value="foo"><br>
|
||||
<textarea id="textarea" width="200">foo</textarea>
|
||||
|
||||
<script>
|
||||
function untilEvent(element, eventName) {
|
||||
return new Promise(resolve => {
|
||||
element.addEventListener(eventName, resolve, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
for (const element of [input, textarea]) {
|
||||
const name = element.localName;
|
||||
for (const focus of [false, true]) {
|
||||
let focused = focus ? " when focused" : "";
|
||||
let offset = focus ? 2 : 1;
|
||||
promise_test(async () => {
|
||||
if (focus) {
|
||||
element.focus();
|
||||
}
|
||||
|
||||
element.setSelectionRange(offset, offset);
|
||||
const ev = await untilEvent(element, "selectionchange");
|
||||
assert_equals(ev.bubbles, true);
|
||||
}, `selectionchange bubbles from ${name}${focused}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user