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

Move overlay tests for dialog/popover into wpt #39570

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html class="reftest-wait">
<title>dialog: close and re-add modal dialog during overlay transition</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element">
<link rel="help" href="https://drafts.csswg.org/css-position-4/#overlay">
<link rel="match" href="pass-dialog-ref.html">
<script src="/common/reftest-wait.js"></script>
<dialog id="dialog1">PASS</dialog>
<dialog id="dialog2">FAIL</dialog>
<style>
dialog::backdrop { background-color: black; }
#dialog1 {
transition-property: overlay, display;
transition-duration: 100s;
}
</style>
<script>
const dialog1 = document.getElementById("dialog1");
const dialog2 = document.getElementById("dialog2");

dialog1.showModal();
dialog2.showModal();
dialog1.close();
requestAnimationFrame(() =>
requestAnimationFrame(() => {
// dialog1 no longer "in top layer" even if rendered in top-layer, should
// be added as last top layer element.
dialog1.showModal();
takeScreenshot();
})
);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<title>dialog: overlay</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element">
<link rel="help" href="https://drafts.csswg.org/css-position-4/#overlay">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<dialog id="dialog"></dialog>
<script>
const dialog = document.getElementById("dialog");

test(() => {
assert_equals(getComputedStyle(dialog).overlay, "none",
"Computed overlay");
// dialog::backdrop {} UA rule always sets overlay to 'auto' even if
// ::backdrop pseudo is not generated. ::backdrop is only generated when the
// dialog is in the top layer.
assert_equals(getComputedStyle(dialog, "::backdrop").overlay, "auto",
"Computed overlay for ::backdrop");
}, "dialog computed overlay initially 'none'");

test(() => {
dialog.showModal();

assert_equals(getComputedStyle(dialog).overlay, "auto",
"Computed overlay on open dialog");
assert_equals(getComputedStyle(dialog, "::backdrop").overlay, "auto",
"Computed overlay for ::backdrop");

dialog.close();

assert_equals(getComputedStyle(dialog).overlay, "none",
"Computed overlay on closed dialog");
// ::backdrop is always overlay:auto. See comment above.
assert_equals(getComputedStyle(dialog, "::backdrop").overlay, "auto",
"Computed overlay for ::backdrop");
}, "Opening and closing a modal dialog changes computed overlay to 'auto' and back to 'none'");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<title>CSS Test Reference</title>
<style>
dialog::backdrop { background-color: black; }
</style>
<dialog id="dialog">PASS</dialog>
<script>
dialog.showModal();
</script>
51 changes: 51 additions & 0 deletions html/semantics/popovers/popover-overlay.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!doctype html>
<title>popover: overlay</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/popover.html#the-popover-attribute">
<link rel="help" href="https://drafts.csswg.org/css-position-4/#overlay">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<dialog popover id="popover-show-dialog"></dialog>
<dialog popover id="popover-show-modal-dialog"></dialog>
<dialog popover id="popover-dialog"></dialog>
<div popover id="popover-div"></div>
<script>
test(() => {
const popover_show_dialog = document.getElementById("popover-show-dialog");
assert_equals(getComputedStyle(popover_show_dialog).overlay, "none",
"Computed overlay");
popover_show_dialog.show();
assert_equals(getComputedStyle(popover_show_dialog).overlay, "none",
"Computed overlay after show()");
popover_show_dialog.close();
}, "dialog.show() should not put popover dialog in top layer");

test(() => {
const popover_show_modal_dialog = document.getElementById("popover-show-modal-dialog");
assert_equals(getComputedStyle(popover_show_modal_dialog).overlay, "none",
"Computed overlay");
popover_show_modal_dialog.showModal();
assert_equals(getComputedStyle(popover_show_modal_dialog).overlay, "auto",
"Computed overlay after showModal()");
popover_show_modal_dialog.close();
}, "dialog.showModal() should put popover dialog in top layer");

test(() => {
const popover_dialog = document.getElementById("popover-dialog");
assert_equals(getComputedStyle(popover_dialog).overlay, "none",
"Computed overlay");
popover_dialog.showPopover();
assert_equals(getComputedStyle(popover_dialog).overlay, "auto",
"Computed overlay after showPopover()");
popover_dialog.hidePopover();
}, "dialog.showPopover() should put popover dialog in top layer");

test(() => {
const popover_div = document.getElementById("popover-div");
assert_equals(getComputedStyle(popover_div).overlay, "none",
"Computed overlay");
popover_div.showPopover();
assert_equals(getComputedStyle(popover_div).overlay, "auto",
"Computed overlay after showPopover()");
popover_div.hidePopover();
}, "div.showPopover() should put popover div in top layer");
</script>