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

Throw exception for popovers/dialogs in non-active documents #48854

Merged
merged 1 commit into from
Oct 30, 2024
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,16 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" href="mailto:[email protected]">
<link rel=help href="https://github.com/whatwg/html/pull/10705">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
test(() => {
const doc = document.implementation.createHTMLDocument();
const dialog = doc.createElement('dialog');
doc.body.appendChild(dialog);
assert_throws_dom('InvalidStateError',() => dialog.showModal());
assert_false(dialog.matches('[open]'));
},'showModal should throw when the document isn\'t active');
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@
doc.body.appendChild(d11);
this.add_cleanup(() => document.body.append(d11));
assert_false(d11.open);
d11.showModal();
assert_true(d11.open);
this.add_cleanup(() => d11.close());
}, "Although the document is not attached to any pages, showModal() should execute as normal.");
assert_throws_dom("INVALID_STATE_ERR", () => d11.showModal());
assert_false(d11.open);
}, "When the document is not attached to any pages, showModal() should throw.");
</script>
17 changes: 17 additions & 0 deletions html/semantics/popovers/popover-active-document.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" href="mailto:[email protected]">
<link rel=help href="https://github.com/whatwg/html/pull/10705">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
test(() => {
const doc = document.implementation.createHTMLDocument();
const popover = doc.createElement('div');
popover.setAttribute('popover','');
doc.body.appendChild(popover);
assert_throws_dom('InvalidStateError',() => popover.showPopover());
assert_false(popover.matches(':open'));
},'showPopover should throw when the document isn\'t active');
</script>