Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for legacy-activation-behaviors #25020

Merged
merged 3 commits into from Aug 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions dom/events/Event-dispatch-click.html
Expand Up @@ -241,6 +241,54 @@
input.dispatchEvent(new MouseEvent("click"));
}, `disabled radio should fire onclick`);

async_test(t => {
const input = document.createElement("input");
input.type = "checkbox";
input.disabled = true;
input.onclick = t.step_func(ev => {
assert_true(input.checked);
ev.preventDefault();
queueMicrotask(t.step_func_done(() => {
assert_false(input.checked);
}));
});
input.dispatchEvent(new MouseEvent("click", { cancelable: true }));
}, `disabled checkbox should get legacy-canceled-activation behavior`);

async_test(t => {
const input = document.createElement("input");
input.type = "radio";
input.disabled = true;
input.onclick = t.step_func(ev => {
assert_true(input.checked);
ev.preventDefault();
queueMicrotask(t.step_func_done(() => {
assert_false(input.checked);
}));
});
input.dispatchEvent(new MouseEvent("click", { cancelable: true }));
}, `disabled radio should get legacy-canceled-activation behavior`);

test(t => {
const input = document.createElement("input");
input.type = "checkbox";
input.disabled = true;
const ev = new MouseEvent("click", { cancelable: true });
ev.preventDefault();
input.dispatchEvent(ev);
assert_false(input.checked);
}, `disabled checkbox should get legacy-canceled-activation behavior 2`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails on Firefox but passes when input.onclick = () => {} is added. The spec does not require such thing, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Nice find.


test(t => {
const input = document.createElement("input");
input.type = "radio";
input.disabled = true;
const ev = new MouseEvent("click", { cancelable: true });
ev.preventDefault();
input.dispatchEvent(ev);
assert_false(input.checked);
}, `disabled radio should get legacy-canceled-activation behavior 2`);

async_test(function(t) {
var form = document.createElement("form")
var didSubmit = false
Expand Down