Skip to content

Commit b2a0371

Browse files
committed
Bug 1927802 [wpt PR 48854] - Throw exception for popovers/dialogs in non-active documents, a=testonly
Automatic update from web-platform-tests Throw exception for popovers/dialogs in non-active documents See discussion at: whatwg/html#10659 and spec PR at: whatwg/html#10705 Web-facing change PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/jRFiIIkXv_k/m/jnPTfg8WBgAJ Fixed: 373684393 Change-Id: I50e400ee526775f915f006865301fff2f04016b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5943740 Reviewed-by: Domenic Denicola <domenicchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Domenic Denicola <domenicchromium.org> Cr-Commit-Position: refs/heads/main{#1375681} -- wpt-commits: 0b99ee5e8c799f9fbf7d1550ef72fec8bdb45760 wpt-pr: 48854 UltraBlame original commit: ac6cc55b745eb0d675d453266bde353b7d335402
1 parent 2e3840c commit b2a0371

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<link rel="author" href="mailto:[email protected]">
4+
<link rel=help href="https://github.com/whatwg/html/pull/10705">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
8+
<script>
9+
test(() => {
10+
const doc = document.implementation.createHTMLDocument();
11+
const dialog = doc.createElement('dialog');
12+
doc.body.appendChild(dialog);
13+
assert_throws_dom('InvalidStateError',() => dialog.showModal());
14+
assert_false(dialog.matches('[open]'));
15+
},'showModal should throw when the document isn\'t active');
16+
</script>

testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@
181181
doc.body.appendChild(d11);
182182
this.add_cleanup(() => document.body.append(d11));
183183
assert_false(d11.open);
184-
d11.showModal();
185-
assert_true(d11.open);
186-
this.add_cleanup(() => d11.close());
187-
}, "Although the document is not attached to any pages, showModal() should execute as normal.");
184+
assert_throws_dom("INVALID_STATE_ERR", () => d11.showModal());
185+
assert_false(d11.open);
186+
}, "When the document is not attached to any pages, showModal() should throw.");
188187
</script>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<link rel="author" href="mailto:[email protected]">
4+
<link rel=help href="https://github.com/whatwg/html/pull/10705">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
8+
<script>
9+
test(() => {
10+
const doc = document.implementation.createHTMLDocument();
11+
const popover = doc.createElement('div');
12+
popover.setAttribute('popover','');
13+
doc.body.appendChild(popover);
14+
assert_throws_dom('InvalidStateError',() => popover.showPopover());
15+
assert_false(popover.matches(':open'));
16+
},'showPopover should throw when the document isn\'t active');
17+
</script>

0 commit comments

Comments
 (0)