Bug 1809689 - Activate first checkbox with activation behaviour. r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D166569
This commit is contained in:
@@ -3133,8 +3133,10 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
|||||||
|
|
||||||
bool originalCheckedValue = false;
|
bool originalCheckedValue = false;
|
||||||
|
|
||||||
if (outerActivateEvent) {
|
if (outerActivateEvent &&
|
||||||
|
!aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented) {
|
||||||
mCheckedIsToggled = false;
|
mCheckedIsToggled = false;
|
||||||
|
aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented = true;
|
||||||
|
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case FormControlType::InputCheckbox: {
|
case FormControlType::InputCheckbox: {
|
||||||
@@ -3147,6 +3149,10 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
|||||||
originalCheckedValue = Checked();
|
originalCheckedValue = Checked();
|
||||||
DoSetChecked(!originalCheckedValue, true, true);
|
DoSetChecked(!originalCheckedValue, true, true);
|
||||||
mCheckedIsToggled = true;
|
mCheckedIsToggled = true;
|
||||||
|
|
||||||
|
if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault) {
|
||||||
|
aVisitor.mEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FormControlType::InputRadio: {
|
case FormControlType::InputRadio: {
|
||||||
@@ -3158,13 +3164,16 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
|||||||
DoSetChecked(true, true, true);
|
DoSetChecked(true, true, true);
|
||||||
mCheckedIsToggled = true;
|
mCheckedIsToggled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault) {
|
||||||
|
aVisitor.mEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FormControlType::InputSubmit:
|
case FormControlType::InputSubmit:
|
||||||
case FormControlType::InputImage:
|
case FormControlType::InputImage:
|
||||||
if (mForm && !aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented) {
|
if (mForm) {
|
||||||
// Make sure other submit elements don't try to trigger submission.
|
// Make sure other submit elements don't try to trigger submission.
|
||||||
aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented = true;
|
|
||||||
aVisitor.mItemFlags |= NS_IN_SUBMIT_CLICK;
|
aVisitor.mItemFlags |= NS_IN_SUBMIT_CLICK;
|
||||||
aVisitor.mItemData = static_cast<Element*>(mForm);
|
aVisitor.mItemData = static_cast<Element*>(mForm);
|
||||||
// tell the form that we are about to enter a click handler.
|
// tell the form that we are about to enter a click handler.
|
||||||
|
|||||||
@@ -4,14 +4,8 @@
|
|||||||
[look at parents only when event bubbles]
|
[look at parents only when event bubbles]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[pick the first with activation behavior <input type=checkbox>]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[event state during post-click handling]
|
[event state during post-click handling]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[redispatch during post-click handling]
|
[redispatch during post-click handling]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[disabled checkbox still has activation behavior, part 2]
|
|
||||||
expected: FAIL
|
|
||||||
|
|||||||
@@ -87,6 +87,22 @@ async_test(function(t) { // as above with <a>
|
|||||||
child.dispatchEvent(new MouseEvent("click", {bubbles:true}))
|
child.dispatchEvent(new MouseEvent("click", {bubbles:true}))
|
||||||
}, "pick the first with activation behavior <a href>")
|
}, "pick the first with activation behavior <a href>")
|
||||||
|
|
||||||
|
async_test(function(t) {
|
||||||
|
var input = document.createElement("input")
|
||||||
|
input.type = "radio"
|
||||||
|
dump.appendChild(input)
|
||||||
|
input.onclick = t.step_func(function() {
|
||||||
|
assert_false(input.checked, "input pre-click must not be triggered")
|
||||||
|
})
|
||||||
|
var child = input.appendChild(document.createElement("input"))
|
||||||
|
child.type = "radio"
|
||||||
|
child.onclick = t.step_func(function() {
|
||||||
|
assert_true(child.checked, "child pre-click must be triggered")
|
||||||
|
})
|
||||||
|
child.dispatchEvent(new MouseEvent("click", {bubbles:true}))
|
||||||
|
t.done()
|
||||||
|
}, "pick the first with activation behavior <input type=radio>")
|
||||||
|
|
||||||
async_test(function(t) {
|
async_test(function(t) {
|
||||||
var input = document.createElement("input")
|
var input = document.createElement("input")
|
||||||
input.type = "checkbox"
|
input.type = "checkbox"
|
||||||
@@ -173,6 +189,46 @@ async_test(function(t) {
|
|||||||
t.done()
|
t.done()
|
||||||
}, "disabled checkbox still has activation behavior, part 2")
|
}, "disabled checkbox still has activation behavior, part 2")
|
||||||
|
|
||||||
|
async_test(function(t) {
|
||||||
|
var state = "start"
|
||||||
|
|
||||||
|
var form = document.createElement("form")
|
||||||
|
form.onsubmit = t.step_func(() => {
|
||||||
|
if(state == "start" || state == "radio") {
|
||||||
|
state = "failure"
|
||||||
|
} else if(state == "form") {
|
||||||
|
state = "done"
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
dump.appendChild(form)
|
||||||
|
var button = form.appendChild(document.createElement("button"))
|
||||||
|
button.type = "submit"
|
||||||
|
var radio = button.appendChild(document.createElement("input"))
|
||||||
|
radio.type = "radio"
|
||||||
|
radio.onclick = t.step_func(() => {
|
||||||
|
if(state == "start") {
|
||||||
|
assert_unreached()
|
||||||
|
} else if(state == "radio") {
|
||||||
|
assert_true(radio.checked)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
radio.disabled = true
|
||||||
|
radio.click()
|
||||||
|
assert_equals(state, "start")
|
||||||
|
|
||||||
|
state = "radio"
|
||||||
|
radio.disabled = false
|
||||||
|
radio.click()
|
||||||
|
assert_equals(state, "radio")
|
||||||
|
|
||||||
|
state = "form"
|
||||||
|
button.click()
|
||||||
|
assert_equals(state, "done")
|
||||||
|
|
||||||
|
t.done()
|
||||||
|
}, "disabled radio still has activation behavior")
|
||||||
|
|
||||||
async_test(function(t) {
|
async_test(function(t) {
|
||||||
var input = document.createElement("input")
|
var input = document.createElement("input")
|
||||||
input.type = "checkbox"
|
input.type = "checkbox"
|
||||||
|
|||||||
Reference in New Issue
Block a user