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:
Brindusan Cristian
2021-07-20 13:29:49 +03:00
parent e1452904c3
commit 0c4fbf4b49
10 changed files with 81 additions and 148 deletions

View File

@@ -884,9 +884,7 @@ nsresult Selection::AddRangesForUserSelectableNodes(
// pref, disabled by default. // pref, disabled by default.
// See https://github.com/w3c/selection-api/issues/53. // See https://github.com/w3c/selection-api/issues/53.
const bool executeDefaultAction = MaybeDispatchSelectstartEvent( const bool executeDefaultAction = MaybeDispatchSelectstartEvent(
*aRange, *aRange, StaticPrefs::dom_select_events_textcontrols_enabled(), doc);
StaticPrefs::dom_select_events_textcontrols_selectstart_enabled(),
doc);
if (!executeDefaultAction) { if (!executeDefaultAction) {
return NS_OK; return NS_OK;

View File

@@ -138,17 +138,15 @@ void SelectionChangeEventDispatcher::OnSelectionChange(Document* aDoc,
// controls, so for now we only support doing that under a pref, disabled by // controls, so for now we only support doing that under a pref, disabled by
// default. // default.
// See https://github.com/w3c/selection-api/issues/53. // See https://github.com/w3c/selection-api/issues/53.
if (textControl && if (textControl && !StaticPrefs::dom_select_events_textcontrols_enabled()) {
!StaticPrefs::dom_select_events_textcontrols_selectionchange_enabled()) {
return; return;
} }
nsCOMPtr<nsINode> target = textControl ? textControl : aDoc; nsCOMPtr<nsINode> target = textControl ? textControl : aDoc;
if (target) { if (target) {
CanBubble canBubble = textControl ? CanBubble::eYes : CanBubble::eNo;
RefPtr<AsyncEventDispatcher> asyncDispatcher = RefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(target, eSelectionChange, canBubble); new AsyncEventDispatcher(target, eSelectionChange, CanBubble::eNo);
asyncDispatcher->PostDOMEvent(); asyncDispatcher->PostDOMEvent();
} }
} }

View File

@@ -348,8 +348,8 @@ TOUCH_EVENT(touchcancel, eTouchCancel, EventNameType_All, eTouchEventClass)
DOCUMENT_ONLY_EVENT(readystatechange, eReadyStateChange, EventNameType_HTMLXUL, DOCUMENT_ONLY_EVENT(readystatechange, eReadyStateChange, EventNameType_HTMLXUL,
eBasicEventClass) eBasicEventClass)
EVENT(selectionchange, eSelectionChange, EventNameType_HTMLXUL, DOCUMENT_ONLY_EVENT(selectionchange, eSelectionChange, EventNameType_HTMLXUL,
eBasicEventClass) eBasicEventClass)
DOCUMENT_ONLY_EVENT(visibilitychange, eVisibilityChange, EventNameType_HTMLXUL, DOCUMENT_ONLY_EVENT(visibilitychange, eVisibilityChange, EventNameType_HTMLXUL,
eBasicEventClass) eBasicEventClass)

View File

@@ -2104,9 +2104,9 @@ void TextControlState::SetSelectionRange(
// XXX(krosylight): Shouldn't it fire before select event? // XXX(krosylight): Shouldn't it fire before select event?
// Currently Gecko and Blink both fire selectionchange after select. // Currently Gecko and Blink both fire selectionchange after select.
if (IsSelectionCached() && if (IsSelectionCached() &&
StaticPrefs::dom_select_events_textcontrols_selectionchange_enabled()) { StaticPrefs::dom_select_events_textcontrols_enabled()) {
asyncDispatcher = new AsyncEventDispatcher( asyncDispatcher = new AsyncEventDispatcher(
mTextCtrlElement, eSelectionChange, CanBubble::eYes); mTextCtrlElement, eSelectionChange, CanBubble::eNo);
asyncDispatcher->PostDOMEvent(); asyncDispatcher->PostDOMEvent();
} }
} }

View File

@@ -34,13 +34,6 @@
}); });
} }
/**
* @param {Node} node
*/
function isProperSelectionChangeTarget(node) {
return node === document || node === input || node === textarea;
}
// The main test // The main test
parent.add_task(async function() { parent.add_task(async function() {
await spin(); await spin();
@@ -53,18 +46,10 @@
var cancel = false; var cancel = false;
var selectstartTarget = null; var selectstartTarget = null;
async function UpdateSelectEventsOnTextControlsPref({ selectstart, selectionchange }) { async function UpdateSelectEventsOntextControlsPref(aEnabled) {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({'set': [['dom.select_events.textcontrols.enabled', aEnabled]]});
'set': [
['dom.select_events.textcontrols.selectstart.enabled', !!selectstart],
['dom.select_events.textcontrols.selectionchange.enabled', !!selectionchange]
]
});
} }
await UpdateSelectEventsOnTextControlsPref({ await UpdateSelectEventsOntextControlsPref(false);
selectstart: false,
selectionchange: false
});
document.addEventListener('selectstart', function(aEvent) { document.addEventListener('selectstart', function(aEvent) {
console.log("originaltarget", aEvent.originalTarget, "new", selectstartTarget); console.log("originaltarget", aEvent.originalTarget, "new", selectstartTarget);
@@ -80,8 +65,8 @@
} }
}); });
document.addEventListener('selectionchange', function(aEvent) { document.addEventListener('selectionchange', function(aEvent) {
ok(isProperSelectionChangeTarget(aEvent.target), is(aEvent.originalTarget, document,
"The target of selectionchange should be one of document, input, or textarea"); "The original target of selectionchange should be the document");
console.log(selectionchange); console.log(selectionchange);
selectionchange++; selectionchange++;
}); });
@@ -346,57 +331,50 @@
// Releasing the mouse shouldn't do anything // Releasing the mouse shouldn't do anything
await mouseAction(elt("input"), 50, "mouseup", 0, 0, 0, 0); await mouseAction(elt("input"), 50, "mouseup", 0, 0, 0, 0);
for (const selectstart of [1, 0]) { await UpdateSelectEventsOntextControlsPref(true);
await UpdateSelectEventsOnTextControlsPref({
selectstart,
selectionchange: true
});
await mouseAction(elt("input"), 40, "mousedown", 0, 1, 1, 0); await mouseAction(elt("input"), 50, "mousedown", 0, 0, 0, 0);
selectstartTarget = elt("input"); 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) // 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"), 75, "mousemove", 0, 0, 1, 0);
await mouseAction(elt("input"), 40, "mousemove", 0, 1, 1, 0); await mouseAction(elt("input"), 50, "mousemove", 0, 0, 1, 0);
// Wiggling the mouse a little such that it doesn't select any // Wiggling the mouse a little such that it doesn't select any
// characters shouldn't trigger a selection // 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 // Moving the mouse again from an empty selection should trigger a
// selectstart // selectstart
selectstartTarget = elt("input"); 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 // Releasing the mouse shouldn't do anything
await mouseAction(elt("input"), 25, "mouseup", 0, 0, 0, 0); await mouseAction(elt("input"), 25, "mouseup", 0, 0, 0, 0);
// And neither should moving your mouse around when the mouse // And neither should moving your mouse around when the mouse
// button isn't pressed // button isn't pressed
await mouseAction(elt("input"), 50, "mousemove", 0, 0, 0, 0); await mouseAction(elt("input"), 50, "mousemove", 0, 0, 0, 0);
// Clicking in an random location should move the selection, but // Clicking in an random location should move the selection, but
// not perform a selectstart // 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 // Clicking there again should do nothing
await mouseAction(elt("input"), 50, "click", 0, 0, 0, 0); await mouseAction(elt("input"), 50, "click", 0, 0, 0, 0);
// Selecting a region, and canceling the selectstart should mean that the // Selecting a region, and canceling the selectstart should mean that the
// selection remains collapsed // 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; cancel = true;
selectstartTarget = elt("input"); 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 mouseAction(elt("input"), 100, "mouseup", 0, 0, 0, 0);
}
await UpdateSelectEventsOnTextControlsPref({
selectstart: false, await UpdateSelectEventsOntextControlsPref(false);
selectionchange: false
});
// Without the dom.select_events.textcontrols.enabled pref, // Without the dom.select_events.textcontrols.enabled pref,
// pressing the mouse shouldn't do anything. // pressing the mouse shouldn't do anything.
@@ -407,52 +385,48 @@
// Releasing the mouse shouldn't do anything // Releasing the mouse shouldn't do anything
await mouseAction(elt("textarea"), 50, "mouseup", 0, 0, 0, 0); await mouseAction(elt("textarea"), 50, "mouseup", 0, 0, 0, 0);
for (const selectstart of [1, 0]) { await UpdateSelectEventsOntextControlsPref(true);
await UpdateSelectEventsOnTextControlsPref({
selectstart,
selectionchange: true
});
// Select a region
await mouseAction(elt("textarea"), 40, "mousedown", 0, 1, 0, 1);
selectstartTarget = elt("textarea"); // Select a region
await mouseAction(elt("textarea"), 100, "mousemove", selectstart, 1, 0, 1); await mouseAction(elt("textarea"), 50, "mousedown", 0, 0, 0, 0);
// Moving it more shouldn't trigger a start (move back to empty) selectstartTarget = elt("textarea");
await mouseAction(elt("textarea"), 75, "mousemove", 0, 1, 0, 1); await mouseAction(elt("textarea"), 100, "mousemove", 1, 0, 0, 1);
await mouseAction(elt("textarea"), 40, "mousemove", 0, 1, 0, 1);
// Wiggling the mouse a little such that it doesn't select any // Moving it more shouldn't trigger a start (move back to empty)
// characters shouldn't trigger a selection await mouseAction(elt("textarea"), 75, "mousemove", 0, 0, 0, 1);
await mouseAction(elt("textarea"), 40, "mousemove", 0, 0, 0, 0, 11); await mouseAction(elt("textarea"), 50, "mousemove", 0, 0, 0, 1);
// Moving the mouse again from an empty selection should trigger a // Wiggling the mouse a little such that it doesn't select any
// selectstart // characters shouldn't trigger a selection
selectstartTarget = elt("textarea"); await mouseAction(elt("textarea"), 50, "mousemove", 0, 0, 0, 0, 11);
await mouseAction(elt("textarea"), 25, "mousemove", selectstart, 1, 0, 1);
// Releasing the mouse shouldn't do anything // Moving the mouse again from an empty selection should trigger a
await mouseAction(elt("textarea"), 25, "mouseup", 0, 0, 0, 0); // selectstart
selectstartTarget = elt("textarea");
await mouseAction(elt("textarea"), 25, "mousemove", 1, 0, 0, 1);
// And neither should moving your mouse around when the mouse // Releasing the mouse shouldn't do anything
// button isn't pressed await mouseAction(elt("textarea"), 25, "mouseup", 0, 0, 0, 0);
await mouseAction(elt("textarea"), 50, "mousemove", 0, 0, 0, 0);
// Clicking in an random location should move the selection, but not perform a // And neither should moving your mouse around when the mouse
// selectstart // button isn't pressed
await mouseAction(elt("textarea"), 50, "click", 0, 1, 0, 1); await mouseAction(elt("textarea"), 50, "mousemove", 0, 0, 0, 0);
// Clicking there again should do nothing // Clicking in an random location should move the selection, but not perform a
await mouseAction(elt("textarea"), 50, "click", 0, 0, 0, 0); // selectstart
await mouseAction(elt("textarea"), 50, "click", 0, 0, 0, 1);
// Selecting a region, and canceling the selectstart should mean that the // Clicking there again should do nothing
// selection remains collapsed await mouseAction(elt("textarea"), 50, "click", 0, 0, 0, 0);
await mouseAction(elt("textarea"), 75, "mousedown", 0, 1, 0, 1);
cancel = true; // Selecting a region, and canceling the selectstart should mean that the
selectstartTarget = elt("textarea"); // selection remains collapsed
await mouseAction(elt("textarea"), 100, "mousemove", selectstart, 1, 0, 1); await mouseAction(elt("textarea"), 75, "mousedown", 0, 0, 0, 1);
await mouseAction(elt("textarea"), 100, "mouseup", 0, 0, 0, 0); cancel = true;
} selectstartTarget = elt("textarea");
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 // 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 // shouldn't trigger any changes, although the nodes will be re-framed

View File

@@ -191,6 +191,8 @@ partial interface Document {
attribute EventHandler onbeforescriptexecute; attribute EventHandler onbeforescriptexecute;
attribute EventHandler onafterscriptexecute; attribute EventHandler onafterscriptexecute;
attribute EventHandler onselectionchange;
/** /**
* True if this document is synthetic : stand alone image, video, audio file, * True if this document is synthetic : stand alone image, video, audio file,
* etc. * etc.

View File

@@ -93,7 +93,6 @@ interface mixin GlobalEventHandlers {
attribute EventHandler onwaiting; attribute EventHandler onwaiting;
attribute EventHandler onselectstart; attribute EventHandler onselectstart;
attribute EventHandler onselectionchange;
attribute EventHandler ontoggle; attribute EventHandler ontoggle;

View File

@@ -3096,12 +3096,7 @@
mirror: always mirror: always
# Whether or not selection events on text controls are enabled. # Whether or not selection events on text controls are enabled.
- name: dom.select_events.textcontrols.selectionchange.enabled - name: dom.select_events.textcontrols.enabled
type: bool
value: true
mirror: always
- name: dom.select_events.textcontrols.selectstart.enabled
type: bool type: bool
value: @IS_NIGHTLY_BUILD@ value: @IS_NIGHTLY_BUILD@
mirror: always mirror: always

View File

@@ -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>