Skip to content

Commit 4f0e058

Browse files
Implement ToggleEvent.source for dialog requestclose
I recently added this to the spec PR after incorporating spec changes for the addition of dialog.requestClose: whatwg/html#11186 Bug: 4080188 Change-Id: Ia6a3a2560349760219a863dba814c5addfa60165 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6598554 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1468857}
1 parent 5e85a42 commit 4f0e058

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

html/semantics/interactive-elements/the-dialog-element/dialog-toggle-source.tentative.html

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
<script src="../../popovers/resources/toggle-event-source-test.js"></script>
1010

1111
<button id=showmodalbutton commandfor=dialog command=show-modal>show modal</button>
12-
<dialog id=dialog>
12+
<button id=lightdismiss>light dismiss</button>
13+
<dialog id=dialog closedby=any>
1314
dialog
1415
<button id=closebutton commandfor=dialog command=close>close</button>
16+
<button id=requestclosebutton commandfor=dialog command=request-close>request close</button>
1517
</dialog>
1618

1719
<script>
1820
const showmodalbutton = document.getElementById('showmodalbutton');
1921
const dialog = document.getElementById('dialog');
22+
const requestclosebutton = document.getElementById('requestclosebutton');
23+
const lightdismiss = document.getElementById('lightdismiss');
2024

2125
createToggleEventSourceTest({
2226
description: 'ToggleEvent.source on <dialog> elements: dialog.showModal().',
@@ -53,4 +57,34 @@
5357
openSource: showmodalbutton,
5458
closeSource: null
5559
});
60+
61+
createToggleEventSourceTest({
62+
description: 'ToggleEvent.source on <dialog> elements: open with showModal, close with request-close button.',
63+
target: dialog,
64+
openFunc: async () => dialog.showModal(),
65+
closeFunc: async () => requestclosebutton.click(),
66+
openSource: null,
67+
closeSource: requestclosebutton
68+
});
69+
70+
createToggleEventSourceTest({
71+
description: 'ToggleEvent.source on <dialog> elements: open with button, close with light dismiss.',
72+
target: dialog,
73+
openFunc: async () => {
74+
await test_driver.click(showmodalbutton);
75+
},
76+
closeFunc: async () => {
77+
dialog.addEventListener('cancel', event => event.preventDefault(), {once: true});
78+
requestclosebutton.click();
79+
assert_true(dialog.matches(':open'),
80+
'cancel preventDefault should have prevented dialog from closing.');
81+
await (new test_driver.Actions()
82+
.pointerMove(0, 0, {origin: lightdismiss})
83+
.pointerDown()
84+
.pointerUp())
85+
.send();
86+
},
87+
openSource: showmodalbutton,
88+
closeSource: null
89+
});
5690
</script>

0 commit comments

Comments
 (0)