Revert "Add HandleInvokeInternal on HTMLDialogElement" (#45103)
This reverts commit 9eab271e13b1698a07ba15a4cf801098c3187d5c.
Suspected to break tests on https://ci.chromium.org/ui/p/chromium/builders/ci/mac11-arm64-rel-tests/35487/overview
Reverting the CL in gerrit failed with some error so I'm manually
reverting it.
Bug: 324601159, 1494810
Change-Id: Iabab8870b5c2d8c40865d5e10df2887b6634c433
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5370574
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Commit-Queue: Nicola Tommasi <tommasin@chromium.org>
Auto-Submit: Christian Dullweber <dullweber@chromium.org>
Owners-Override: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: Nicola Tommasi <tommasin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1272680}
Co-authored-by: Christian Dullweber <dullweber@chromium.org>
diff --git a/html/semantics/invokers/invoketarget-on-dialog-behavior.tentative.html b/html/semantics/invokers/invoketarget-on-dialog-behavior.tentative.html
deleted file mode 100644
index 774d308..0000000
--- a/html/semantics/invokers/invoketarget-on-dialog-behavior.tentative.html
+++ /dev/null
@@ -1,455 +0,0 @@
-<!doctype html>
-<meta charset="utf-8" />
-<meta name="author" title="Keith Cirkel" href="mailto:wpt@keithcirkel.co.uk" />
-<meta name="timeout" content="long">
-<link rel="help" href="https://open-ui.org/components/invokers.explainer/" />
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="/resources/testdriver.js"></script>
-<script src="/resources/testdriver-actions.js"></script>
-<script src="/resources/testdriver-vendor.js"></script>
-<script src="resources/invoker-utils.js"></script>
-
-<dialog id="invokee">
- <button id="containedinvoker" invoketarget="invokee"></button>
-</dialog>
-<button id="invokerbutton" invoketarget="invokee"></button>
-
-<script>
- function resetState() {
- invokee.close();
- try { invokee.hidePopover(); } catch {}
- invokee.removeAttribute("popover");
- invokerbutton.removeAttribute("invokeaction");
- containedinvoker.removeAttribute("invokeaction");
- }
-
- // opening a dialog
-
- [null, "", "showmodal", /* test case sensitivity */ "sHoWmOdAl"].forEach(
- (action) => {
- ["property", "attribute"].forEach((setType) => {
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- if (typeof action === "string") {
- if (setType === "property") {
- invokerbutton.invokeaction = action;
- } else {
- invokerbutton.setAttribute("invokeaction", action);
- }
- }
- await clickOn(invokerbutton);
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) closed dialog opens as modal`,
- );
-
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- invokee.addEventListener("invoke", (e) => e.preventDefault(), {
- once: true,
- });
- if (typeof action === "string") {
- if (setType === "property") {
- invokerbutton.invokeaction = action;
- } else {
- invokerbutton.setAttribute("invokeaction", action);
- }
- }
- await clickOn(invokerbutton);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) closed dialog with preventDefault is noop`,
- );
-
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- invokee.addEventListener(
- "invoke",
- (e) => {
- invokerbutton.setAttribute("invokeaction", "close");
- },
- { once: true },
- );
- if (typeof action === "string") {
- if (setType === "property") {
- invokerbutton.invokeaction = action;
- } else {
- invokerbutton.setAttribute("invokeaction", action);
- }
- }
- await clickOn(invokerbutton);
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) while changing action still opens as modal`,
- );
- });
- },
- );
-
- // closing an already open dialog
-
- [null, "", "close", /* test case sensitivity */ "cLoSe"].forEach((action) => {
- ["property", "attribute"].forEach((setType) => {
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- invokee.show();
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- if (typeof action === "string") {
- if (setType === "property") {
- containedinvoker.invokeaction = action;
- } else {
- containedinvoker.setAttribute("invokeaction", action);
- }
- }
- await clickOn(containedinvoker);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking to close (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) open dialog closes`,
- );
-
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- invokee.show();
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- if (typeof action === "string") {
- if (setType === "property") {
- containedinvoker.invokeaction = action;
- } else {
- containedinvoker.setAttribute("invokeaction", action);
- }
- }
- invokee.addEventListener("invoke", (e) => e.preventDefault(), {
- once: true,
- });
- await clickOn(containedinvoker);
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking to close (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) open dialog with preventDefault is no-op`,
- );
-
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- invokee.showModal();
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- if (typeof action === "string") {
- if (setType === "property") {
- containedinvoker.invokeaction = action;
- } else {
- containedinvoker.setAttribute("invokeaction", action);
- }
- }
- invokee.addEventListener("invoke", (e) => e.preventDefault(), {
- once: true,
- });
- await clickOn(containedinvoker);
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking to close (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) open modal dialog with preventDefault is no-op`,
- );
-
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- invokee.show();
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- if (typeof action === "string") {
- if (setType === "property") {
- containedinvoker.invokeaction = action;
- } else {
- containedinvoker.setAttribute("invokeaction", action);
- }
- }
- invokee.addEventListener(
- "invoke",
- (e) => {
- containedinvoker.setAttribute("invokeaction", "show");
- },
- { once: true },
- );
- await clickOn(containedinvoker);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking to close (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) open dialog while changing action still closes`,
- );
-
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- invokee.showModal();
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- if (typeof action === "string") {
- if (setType === "property") {
- containedinvoker.invokeaction = action;
- } else {
- containedinvoker.setAttribute("invokeaction", action);
- }
- }
- invokee.addEventListener(
- "invoke",
- (e) => {
- containedinvoker.setAttribute("invokeaction", "show");
- },
- { once: true },
- );
- await clickOn(containedinvoker);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking to close (with invokeaction ${setType} as ${
- action == null ? "auto" : action || "explicit empty"
- }) open modal dialog while changing action still closes`,
- );
- });
- });
-
- // showmodal explicit behaviours
-
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- containedinvoker.setAttribute("invokeaction", "showModal");
- invokee.show();
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- await clickOn(containedinvoker);
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- }, "invoking (as showmodal) open dialog is noop");
-
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- containedinvoker.setAttribute("invokeaction", "showmodal");
- invokee.showModal();
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- invokee.addEventListener(
- "invoke",
- (e) => {
- containedinvoker.setAttribute("invokeaction", "close");
- },
- { once: true },
- );
- await clickOn(invokerbutton);
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- }, "invoking (as showmodal) open modal, while changing action still a no-op");
-
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- invokerbutton.setAttribute("invokeaction", "showmodal");
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- invokee.setAttribute("popover", "auto");
- await clickOn(invokerbutton);
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- }, "invoking (as showmodal) closed popover dialog opens as modal");
-
- // close explicit behaviours
-
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- invokerbutton.setAttribute("invokeaction", "close");
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- await clickOn(containedinvoker);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- }, "invoking (as close) already closed dialog is noop");
-
- // invalid
- [
- "foo",
- "foo-bar",
- "auto",
- "showpopover",
- "hidepopover",
- "togglepopover",
- "showpicker",
- ].forEach((action) => {
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- invokerbutton.setAttribute("invokeaction", action);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- await clickOn(invokerbutton);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- }, `invoking (as ${action}) on dialog does nothing`);
-
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- containedinvoker.setAttribute("invokeaction", action);
- invokee.show();
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- await clickOn(containedinvoker);
- assert_true(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- }, `invoking (as ${action}) on open dialog does nothing`);
-
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- containedinvoker.setAttribute("invokeaction", action);
- invokee.showModal();
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- await clickOn(containedinvoker);
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- }, `invoking (as ${action}) on open modal dialog does nothing`);
-
- promise_test(async function (t) {
- t.add_cleanup(resetState);
- containedinvoker.setAttribute("invokeaction", action);
- invokee.showModal();
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- invokee.addEventListener(
- "invoke",
- (e) => {
- containedinvoker.setAttribute("invokeaction", "");
- },
- { once: true },
- );
- await clickOn(containedinvoker);
- assert_true(invokee.open, "invokee.open");
- assert_true(invokee.matches(":modal"), "invokee :modal");
- }, `invoking (as ${action}) on open modal while changing the attributer does nothing`);
- });
-
- // Open Popovers using Dialog actions
- ["showmodal", "close", ""].forEach((action) => {
- ["manual", "auto"].forEach((popoverState) => {
- promise_test(
- async function (t) {
- t.add_cleanup(resetState);
- invokee.setAttribute("popover", popoverState);
- invokee.showPopover();
- containedinvoker.setAttribute("invokeaction", action);
- assert_true(
- invokee.matches(":popover-open"),
- "invokee :popover-open",
- );
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- invokee.addEventListener("invoke", (e) => e.preventDefault(), {
- once: true,
- });
- await clickOn(containedinvoker);
- assert_true(
- invokee.matches(":popover-open"),
- "invokee :popover-open",
- );
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking (as ${
- action || "explicit empty"
- }) dialog as open popover=${popoverState} is noop`,
- );
- });
- });
-
- // Elements being disconnected during invoke steps
- ["showmodal", "close", ""].forEach((action) => {
- promise_test(
- async function (t) {
- t.add_cleanup(() => {
- document.body.prepend(invokee);
- resetState();
- });
- const invokee = document.querySelector("#invokee");
- invokerbutton.setAttribute("invokeaction", action);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- invokee.addEventListener(
- "invoke",
- (e) => {
- invokee.remove();
- },
- {
- once: true,
- },
- );
- await clickOn(invokerbutton);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking (as ${
- action || "explicit empty"
- }) dialog that is removed is noop`,
- );
-
- promise_test(
- async function (t) {
- const invokerbutton = document.createElement("button");
- invokerbutton.invokeTargetElement = invokee;
- invokerbutton.setAttribute("invokeaction", action);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- await clickOn(invokerbutton);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking (as ${
- action || "explicit empty"
- }) dialog from a detached invoker`,
- );
-
- promise_test(
- async function (t) {
- const invokerbutton = document.createElement("button");
- const invokee = document.createElement("dialog");
- invokerbutton.invokeTargetElement = invokee;
- invokerbutton.setAttribute("invokeaction", action);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- await clickOn(invokerbutton);
- assert_false(invokee.open, "invokee.open");
- assert_false(invokee.matches(":modal"), "invokee :modal");
- },
- `invoking (as ${
- action || "explicit empty"
- }) detached dialog from a detached invoker`,
- );
- });
-</script>
diff --git a/html/semantics/invokers/invoketarget-on-popover-behavior.tentative.html b/html/semantics/invokers/invoketarget-on-popover-behavior.tentative.html
index 2bddfa7..03eba22 100644
--- a/html/semantics/invokers/invoketarget-on-popover-behavior.tentative.html
+++ b/html/semantics/invokers/invoketarget-on-popover-behavior.tentative.html
@@ -10,7 +10,7 @@
<script src="resources/invoker-utils.js"></script>
<div id="invokee" popover>
- <button id="containedinvoker" invoketarget="invokee"></button>
+ <button id="invokerbutton2" invoketarget="invokee"></button>
</div>
<button id="invokerbutton" invoketarget="invokee"></button>
@@ -44,7 +44,7 @@
promise_test(async function (t) {
invokee.showPopover();
assert_true(invokee.matches(":popover-open"));
- await clickOn(containedinvoker);
+ await clickOn(invokerbutton2);
assert_false(invokee.matches(":popover-open"));
}, "invoking (as auto) from within open popover closes");
@@ -55,7 +55,7 @@
once: true,
});
assert_true(invokee.matches(":popover-open"));
- await clickOn(containedinvoker);
+ await clickOn(invokerbutton2);
assert_true(invokee.matches(":popover-open"));
}, "invoking (as auto) open popover with preventDefault does not close");
@@ -93,8 +93,8 @@
promise_test(async function (t) {
invokee.showPopover();
- containedinvoker.setAttribute("invokeaction", "togglepopover");
- t.add_cleanup(() => containedinvoker.removeAttribute("invokeaction"));
+ invokerbutton2.setAttribute("invokeaction", "togglepopover");
+ t.add_cleanup(() => invokerbutton2.removeAttribute("invokeaction"));
assert_true(invokee.matches(":popover-open"));
await clickOn(invokerbutton);
assert_false(invokee.matches(":popover-open"));
@@ -102,23 +102,23 @@
promise_test(async function (t) {
invokee.showPopover();
- containedinvoker.setAttribute("invokeaction", "togglepopover");
- t.add_cleanup(() => containedinvoker.removeAttribute("invokeaction"));
+ invokerbutton2.setAttribute("invokeaction", "togglepopover");
+ t.add_cleanup(() => invokerbutton2.removeAttribute("invokeaction"));
assert_true(invokee.matches(":popover-open"));
- await clickOn(containedinvoker);
+ await clickOn(invokerbutton2);
assert_false(invokee.matches(":popover-open"));
}, "invoking (as togglepopover) from within open popover closes");
promise_test(async function (t) {
invokee.showPopover();
t.add_cleanup(() => invokee.hidePopover());
- containedinvoker.setAttribute("invokeaction", "togglepopover");
- t.add_cleanup(() => containedinvoker.removeAttribute("invokeaction"));
+ invokerbutton2.setAttribute("invokeaction", "togglepopover");
+ t.add_cleanup(() => invokerbutton2.removeAttribute("invokeaction"));
invokee.addEventListener("invoke", (e) => e.preventDefault(), {
once: true,
});
assert_true(invokee.matches(":popover-open"));
- await clickOn(containedinvoker);
+ await clickOn(invokerbutton2);
assert_true(invokee.matches(":popover-open"));
}, "invoking (as togglepopover) open popover with preventDefault does not close");
@@ -175,59 +175,35 @@
}, "invoking (as hidepopover) closed popover is noop");
promise_test(async function (t) {
- containedinvoker.setAttribute("invokeaction", "hidepopover");
- t.add_cleanup(() => containedinvoker.removeAttribute("invokeaction"));
+ invokerbutton2.setAttribute("invokeaction", "hidepopover");
+ t.add_cleanup(() => invokerbutton2.removeAttribute("invokeaction"));
invokee.showPopover();
assert_true(invokee.matches(":popover-open"));
- await clickOn(containedinvoker);
+ await clickOn(invokerbutton2);
t.add_cleanup(() => invokee.hidePopover());
assert_false(invokee.matches(":popover-open"));
}, "invoking (as hidepopover) open popover closes");
promise_test(async function (t) {
- containedinvoker.setAttribute("invokeaction", "hIdEpOpOvEr");
- t.add_cleanup(() => containedinvoker.removeAttribute("invokeaction"));
+ invokerbutton2.setAttribute("invokeaction", "hIdEpOpOvEr");
+ t.add_cleanup(() => invokerbutton2.removeAttribute("invokeaction"));
invokee.showPopover();
assert_true(invokee.matches(":popover-open"));
- await clickOn(containedinvoker);
+ await clickOn(invokerbutton2);
t.add_cleanup(() => invokee.hidePopover());
assert_false(invokee.matches(":popover-open"));
}, "invoking (as hidepopover - case insensitive) open popover closes");
promise_test(async function (t) {
- containedinvoker.setAttribute("invokeaction", "hidepopover");
- t.add_cleanup(() => containedinvoker.removeAttribute("invokeaction"));
+ invokerbutton2.setAttribute("invokeaction", "hidepopover");
+ t.add_cleanup(() => invokerbutton2.removeAttribute("invokeaction"));
invokee.showPopover();
t.add_cleanup(() => invokee.hidePopover());
assert_true(invokee.matches(":popover-open"));
invokee.addEventListener("invoke", (e) => e.preventDefault(), {
once: true,
});
- await clickOn(containedinvoker);
+ await clickOn(invokerbutton2);
assert_true(invokee.matches(":popover-open"));
}, "invoking (as hidepopover) open popover with preventDefault does not close");
-
- // invalid
-
- ["foo", "togglemodal", "showpicker", "toggle", "open", "close"].forEach(action => {
- promise_test(async function (t) {
- invokerbutton.setAttribute("invokeaction", action);
- t.add_cleanup(() => invokerbutton.removeAttribute("invokeaction"));
- assert_false(invokee.matches(":popover-open"));
- await clickOn(invokerbutton);
- assert_false(invokee.matches(":popover-open"));
- }, `invoking (as ${action}) on popover does nothing`);
-
- promise_test(async function (t) {
- invokerbutton.setAttribute("invokeaction", action);
- t.add_cleanup(() => {
- invokerbutton.removeAttribute("invokeaction")
- invokee.hidePopover();
- });
- invokee.showPopover()
- assert_true(invokee.matches(":popover-open"));
- await clickOn(invokerbutton);
- assert_true(invokee.matches(":popover-open"));
- }, `invoking (as ${action}) on open popover does nothing`);
- })
</script>
diff --git a/html/semantics/invokers/resources/invoker-utils.js b/html/semantics/invokers/resources/invoker-utils.js
index 8420f24..3179455 100644
--- a/html/semantics/invokers/resources/invoker-utils.js
+++ b/html/semantics/invokers/resources/invoker-utils.js
@@ -2,13 +2,9 @@
return new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
}
async function clickOn(element) {
+ const actions = new test_driver.Actions();
await waitForRender();
- let rect = element.getBoundingClientRect();
- let actions = new test_driver.Actions();
- // FIXME: Switch to pointerMove(0, 0, {origin: element}) once
- // https://github.com/web-platform-tests/wpt/issues/41257 is fixed.
- await actions
- .pointerMove(Math.round(rect.x + rect.width / 2), Math.round(rect.y + rect.height / 2), {})
+ await actions.pointerMove(0, 0, {origin: element})
.pointerDown({button: actions.ButtonType.LEFT})
.pointerUp({button: actions.ButtonType.LEFT})
.send();