From a9e284e0db395d4f62c81e996abd487ffca48a3f Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 14 Nov 2022 14:44:14 +0000 Subject: [PATCH] Bug 1799565 - Allow pointer events on disabled form elements on Nightly r=smaug Corresponds to the latest consensus and also matches what Chrome shipped behind `--enable-blink-features=SendMouseEventsDisabledFormControls`. Imported the portion of tests that is directly impacted here from https://github.com/web-platform-tests/wpt/pull/32381. Others are not directly impacted and thus I'd like to land them separately since there are still some mismatching behavior around `button` element. Differential Revision: https://phabricator.services.mozilla.com/D161537 --- dom/html/nsGenericHTMLElement.cpp | 6 + modules/libpref/init/StaticPrefList.yaml | 5 + ...disabled-event-dispatch.tentative.html.ini | 12 - ...ointerevent_disabled_form_control.html.ini | 12 +- .../event-propagate-disabled.tentative.html | 243 ++++++++++++++++++ .../pointerevent_disabled_form_control.html | 9 +- 6 files changed, 262 insertions(+), 25 deletions(-) delete mode 100644 testing/web-platform/meta/html/semantics/disabled-elements/disabled-event-dispatch.tentative.html.ini create mode 100644 testing/web-platform/tests/html/semantics/disabled-elements/event-propagate-disabled.tentative.html diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index b43eb52840ffd..d6b614e58c712 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -1968,6 +1968,12 @@ bool nsGenericHTMLFormElement::IsElementDisabledForEvents(WidgetEvent* aEvent, case eLegacyMouseLineOrPageScroll: case eLegacyMousePixelScroll: return false; + case ePointerDown: + case ePointerUp: + case ePointerCancel: + case ePointerGotCapture: + case ePointerLostCapture: + return !StaticPrefs::dom_forms_always_allow_pointer_events_enabled(); default: break; } diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 9b954d67d33c0..74ae97e5ded75 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -2894,6 +2894,11 @@ value: true mirror: always +- name: dom.forms.always_allow_pointer_events.enabled + type: bool + value: @IS_NIGHTLY_BUILD@ + mirror: always + # Is support for HTMLInputElement.showPicker enabled? - name: dom.input.showPicker type: bool diff --git a/testing/web-platform/meta/html/semantics/disabled-elements/disabled-event-dispatch.tentative.html.ini b/testing/web-platform/meta/html/semantics/disabled-elements/disabled-event-dispatch.tentative.html.ini deleted file mode 100644 index 2bd4b95b31f74..0000000000000 --- a/testing/web-platform/meta/html/semantics/disabled-elements/disabled-event-dispatch.tentative.html.ini +++ /dev/null @@ -1,12 +0,0 @@ -[disabled-event-dispatch.tentative.html] - [Testing pointerdown events when clicking child of disabled form controls.] - expected: FAIL - - [Testing pointerdown events when clicking disabled form controls.] - expected: FAIL - - [Testing pointerup events when clicking child of disabled form controls.] - expected: FAIL - - [Testing pointerup events when clicking disabled form controls.] - expected: FAIL diff --git a/testing/web-platform/meta/pointerevents/pointerevent_disabled_form_control.html.ini b/testing/web-platform/meta/pointerevents/pointerevent_disabled_form_control.html.ini index d6bb72ba6115d..cedf82737e9ff 100644 --- a/testing/web-platform/meta/pointerevents/pointerevent_disabled_form_control.html.ini +++ b/testing/web-platform/meta/pointerevents/pointerevent_disabled_form_control.html.ini @@ -1,15 +1,5 @@ -[pointerevent_disabled_form_control.html?mouse] - expected: TIMEOUT - [mouse pointerevent attributes] - expected: NOTRUN - - +prefs: [dom.forms.always_allow_pointer_events.enabled:true] [pointerevent_disabled_form_control.html?pen] expected: if (os == "android") and fission: [ERROR, TIMEOUT] ERROR - -[pointerevent_disabled_form_control.html?touch] - expected: TIMEOUT - [touch pointerevent attributes] - expected: NOTRUN diff --git a/testing/web-platform/tests/html/semantics/disabled-elements/event-propagate-disabled.tentative.html b/testing/web-platform/tests/html/semantics/disabled-elements/event-propagate-disabled.tentative.html new file mode 100644 index 0000000000000..0c00cc8db078b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/disabled-elements/event-propagate-disabled.tentative.html @@ -0,0 +1,243 @@ + + + +Event propagation on disabled form elements + + + + + + + + + +
+ + + +
Text
+
Span
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/pointerevents/pointerevent_disabled_form_control.html b/testing/web-platform/tests/pointerevents/pointerevent_disabled_form_control.html index 83ad053a146a9..d253111115f1e 100644 --- a/testing/web-platform/tests/pointerevents/pointerevent_disabled_form_control.html +++ b/testing/web-platform/tests/pointerevents/pointerevent_disabled_form_control.html @@ -18,7 +18,7 @@ var inputSource = location.search.substring(1); var detected_pointertypes = {}; var detected_eventTypes = {}; - var eventList = ['pointerout', 'pointerover', 'pointerenter', 'pointermove', 'pointerdown', 'pointerup', 'pointerleave']; + var eventList = ['pointerout', 'pointerover', 'pointerenter', 'pointermove', 'pointerdown', 'gotpointercapture', 'pointerup', 'lostpointercapture', 'pointerleave']; function resetTestState() { detected_eventTypes = {}; @@ -29,10 +29,14 @@ var actions_promise; eventList.forEach(function(eventName) { - on_event(target, eventName, function (event) { + on_event(target, eventName, function (event) { detected_eventTypes[event.type] = true; detected_pointertypes[event.pointerType] = true; + if (event.type === "pointerdown") { + target.setPointerCapture(event.pointerId); + } + if (Object.keys(detected_eventTypes).length == eventList.length) { // Make sure the test finishes after all the input actions are completed. actions_promise.then( () => { @@ -55,6 +59,7 @@ actions_promise = clickInTarget(inputSource, target).then(function() { return new test_driver.Actions() .addPointer(inputSource + "Pointer1", inputSource) + .pointerMove(0, 0, {origin: target}) .pointerMove(0, 0) .send(); });