Bug 1520869 - Allow input/change events on disabled radio/checkboxes r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D102517
This commit is contained in:
Kagami Sascha Rosylight 2021-01-21 14:18:18 +00:00
Родитель 2838080937
Коммит 4460528639
2 изменённых файлов: 22 добавлений и 0 удалений

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

@ -2071,6 +2071,7 @@ bool nsGenericHTMLFormElement::IsElementDisabledForEvents(WidgetEvent* aEvent,
case eAnimationEnd:
case eAnimationIteration:
case eAnimationCancel:
case eFormChange:
case eMouseMove:
case eMouseOver:
case eMouseOut:
@ -2093,6 +2094,10 @@ bool nsGenericHTMLFormElement::IsElementDisabledForEvents(WidgetEvent* aEvent,
break;
}
if (aEvent->mSpecifiedEventType == nsGkAtoms::oninput) {
return false;
}
// FIXME(emilio): This poking at the style of the frame is slightly bogus
// unless we flush before every event, which we don't really want to do.
if (aFrame && aFrame->StyleUI()->mUserInput == StyleUserInput::None) {

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

@ -289,6 +289,23 @@ test(t => {
assert_false(input.checked);
}, `disabled radio should get legacy-canceled-activation behavior 2`);
for (const type of ["checkbox", "radio"]) {
for (const handler of ["oninput", "onchange"]) {
async_test(t => {
const input = document.createElement("input");
input.type = type;
input.onclick = t.step_func(ev => {
input.disabled = true;
});
input[handler] = t.step_func(ev => {
assert_equals(input.checked, true);
t.done();
});
input.click();
}, `disabling ${type} in onclick listener shouldn't suppress ${handler}`);
}
}
async_test(function(t) {
var form = document.createElement("form")
var didSubmit = false