Bug 1887947 [wpt PR 45333] - Revert "[Invokers] Only dispatch invoke for built-ins or actions containing '-'", a=testonly

Automatic update from web-platform-tests
Revert "[Invokers] Only dispatch invoke for built-ins or actions containing '-'"

This reverts commit 87ca363c4a89ce638bb9dbfba8ad71b967e1bcbe.

Reason for revert: invoketarget-on-details-invalid-behavior.tentative.html failing on multiple builders

Original change's description:
> [Invokers] Only dispatch invoke for built-ins or actions containing '-'
>
> (This relands
> https://chromium-review.googlesource.com/c/chromium/src/+/5366502 after
> fixing timeout issues in
> https://chromium-review.googlesource.com/c/chromium/src/+/5372478)
>
> This change refactors the `HandleInvokeInternal` calls to use an enum
> class of known attribute values including a `kCustom` key which can determine if the invoke action meets the criteria for being
> a "custom" action - that is it includes a dash (see
> b40ba866cc).
>
> This also updates the tests to reflect this; only actions with a `-`, or
> otherwise known actions, will dispatch an event. All other actions do
> not, and must be manually dispatched. This does not preclude web authors
> from manually dispatching said events.
>
> Bug: 40947660
> Change-Id: Ie6efeac7991c449b54d0c8b7ed360501ae5c8d37
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5388656
> Reviewed-by: Joey Arhar <jarhar@chromium.org>
> Reviewed-by: Mason Freed <masonf@chromium.org>
> Auto-Submit: Keith Cirkel <chromium@keithcirkel.co.uk>
> Commit-Queue: Joey Arhar <jarhar@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1277851}

Bug: 40947660
Change-Id: I89f4d5efaba810d345c571d558cb826b263dd907
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5393427
Owners-Override: Matt Reynolds <mattreynolds@chromium.org>
Auto-Submit: Matt Reynolds <mattreynolds@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1278027}

--

wpt-commits: 42060952b73d4d25a12149adfdafbfe17c4562b9
wpt-pr: 45333
This commit is contained in:
Matt Reynolds 2024-03-27 23:09:17 +00:00 committed by moz-wptsync-bot
parent 3f9fba21ad
commit 04477ef239

View File

@ -28,63 +28,35 @@
assert_equals(event.invoker, invokerbutton, "invoker");
}, "event dispatches on click");
// valid custom invokeactions
["-foo", "foo-", "cAsE-cArRiEs", "-", "-a-", "a-b", "---", "show-picker"].forEach(
(action) => {
promise_test(async function (t) {
t.add_cleanup(() => invokerbutton.removeAttribute("invokeaction"));
let event = null;
invokee.addEventListener("invoke", (e) => (event = e), { once: true });
invokerbutton.invokeAction = action;
await clickOn(invokerbutton);
assert_true(event instanceof InvokeEvent, "event is InvokeEvent");
assert_equals(event.type, "invoke", "type");
assert_equals(event.bubbles, false, "bubbles");
assert_equals(event.composed, true, "composed");
assert_equals(event.isTrusted, true, "isTrusted");
assert_equals(event.action, action, "action");
assert_equals(event.target, invokee, "target");
assert_equals(event.invoker, invokerbutton, "invoker");
}, `setting custom invokeAction property to ${action} (must include dash) sets event action`);
promise_test(async function (t) {
let event = null;
invokee.addEventListener("invoke", (e) => (event = e), { once: true });
invokerbutton.invokeAction = "fooBar";
await clickOn(invokerbutton);
assert_true(event instanceof InvokeEvent, "event is InvokeEvent");
assert_equals(event.type, "invoke", "type");
assert_equals(event.bubbles, false, "bubbles");
assert_equals(event.composed, true, "composed");
assert_equals(event.isTrusted, true, "isTrusted");
assert_equals(event.action, "fooBar", "action");
assert_equals(event.target, invokee, "target");
assert_equals(event.invoker, invokerbutton, "invoker");
}, "event action is set to invokeAction");
promise_test(async function (t) {
t.add_cleanup(() => invokerbutton.removeAttribute("invokeaction"));
let event = null;
invokee.addEventListener("invoke", (e) => (event = e), { once: true });
invokerbutton.setAttribute("invokeaction", action);
await clickOn(invokerbutton);
assert_true(event instanceof InvokeEvent, "event is InvokeEvent");
assert_equals(event.type, "invoke", "type");
assert_equals(event.bubbles, false, "bubbles");
assert_equals(event.composed, true, "composed");
assert_equals(event.isTrusted, true, "isTrusted");
assert_equals(event.action, action, "action");
assert_equals(event.target, invokee, "target");
assert_equals(event.invoker, invokerbutton, "invoker");
}, `setting custom invokeaction attribute to ${action} (must include dash) sets event action`);
},
);
// invalid custom invokeactions
["foo", "foobar", "foo bar", "em—dash", "hidedocument"].forEach((action) => {
promise_test(async function (t) {
t.add_cleanup(() => invokerbutton.removeAttribute("invokeaction"));
let event = null;
invokee.addEventListener("invoke", (e) => (event = e), { once: true });
invokerbutton.invokeAction = action;
await clickOn(invokerbutton);
assert_equals(event, null, "event should not have fired");
}, `setting custom invokeAction property to ${action} (no dash) did not dispatch an event`);
promise_test(async function (t) {
t.add_cleanup(() => invokerbutton.removeAttribute("invokeaction"));
let event = null;
invokee.addEventListener("invoke", (e) => (event = e), { once: true });
invokerbutton.setAttribute("invokeaction", action);
await clickOn(invokerbutton);
assert_equals(event, null, "event should not have fired");
}, `setting custom invokeaction attribute to ${action} (no dash) did not dispatch an event`);
});
promise_test(async function (t) {
let event = null;
invokee.addEventListener("invoke", (e) => (event = e), { once: true });
invokerbutton.setAttribute("invokeaction", "BaRbAz");
await clickOn(invokerbutton);
assert_true(event instanceof InvokeEvent, "event is InvokeEvent");
assert_equals(event.type, "invoke", "type");
assert_equals(event.bubbles, false, "bubbles");
assert_equals(event.composed, true, "composed");
assert_equals(event.isTrusted, true, "isTrusted");
assert_equals(event.action, "BaRbAz", "action");
assert_equals(event.target, invokee, "target");
assert_equals(event.invoker, invokerbutton, "invoker");
}, "event action is set to invokeaction attribute");
promise_test(async function (t) {
let called = false;
@ -107,7 +79,7 @@
}, "event does not dispatch if click:preventDefault is called");
promise_test(async function (t) {
t.add_cleanup(() => invokerbutton.removeAttribute("disabled"));
t.add_cleanup(() => invokerbutton.removeAttribute('disabled'));
let called = false;
invokee.addEventListener(
"invoke",
@ -122,7 +94,7 @@
}, "event does not dispatch if invoker is disabled");
promise_test(async function (t) {
svgInvokee = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svgInvokee = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
t.add_cleanup(() => {
invokerbutton.invokeTargetElement = invokee;
svgInvokee.remove();
@ -144,15 +116,7 @@
invokerbutton.invokeTargetElement = svgInvokee;
await clickOn(invokerbutton);
assert_true(called, "event was called");
assert_equals(
eventInvoker,
invokerbutton,
"event.invoker is set to right element",
);
assert_equals(
eventTarget,
svgInvokee,
"event.target is set to right element",
);
assert_equals(eventInvoker, invokerbutton, "event.invoker is set to right element");
assert_equals(eventTarget, svgInvokee, "event.target is set to right element");
}, "event dispatches if invokee is non-HTML Element");
</script>