forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[inert] The modal dialog and the fullscreen element should escape ine…
…rtness of ancestor According to the spec: https://html.spec.whatwg.org/#modal-dialogs-and-inert-subtrees > While document is so blocked, every node that is connected to > document, with the exception of the subject element and its flat tree > descendants, must become inert. subject can additionally become inert > via the inert attribute, but only if specified on subject itself > (i.e., subject escapes inertness of ancestors); subject's flat tree > descendants can become inert in a similar fashion. The modal dialog should escape the inertness set by an ancestor with the inert attribute. Consider this test case: <div inert> <dialog>find me!</dialog> </div> <script>document.querySelector("dialog").showModal()</script> The return value of `window.find('me')` should be true, because `<dialog>` does not specify the inert attribute. Bug: 328339024 Change-Id: Ib6d0aa00d63740b4e13457c38e4602a595bb26ba Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5348000 Reviewed-by: Kent Tamura <[email protected]> Reviewed-by: Koji Ishii <[email protected]> Commit-Queue: Peng Zhou <[email protected]> Cr-Commit-Position: refs/heads/main@{#1270044}
- Loading branch information
1 parent
b3a83a9
commit 6a94e0f
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8" /> | ||
<title>Interaction of 'inert' attribute with fullscreen element</title> | ||
<link rel="author" title="Peng Zhou" href="mailto:[email protected]"> | ||
<meta name="assert" content="Checks that fullscreen element inertness from ancestors."> | ||
<div id="wrapper"> | ||
wrapper | ||
<span> | ||
wrapper-child element | ||
</span> | ||
<div id="fullscreen"> | ||
fullscreen | ||
<span id="child"> | ||
child | ||
</span> | ||
</div> | ||
</div> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script> | ||
async function cleanup() { | ||
if (document.fullscreenElement) { | ||
await document.exitFullscreen(); | ||
} | ||
getSelection().removeAllRanges(); | ||
} | ||
|
||
async function setupTest(element, context) { | ||
element.inert = true; | ||
await test_driver.bless("request full screen"); | ||
await fullscreen.requestFullscreen(); | ||
context.add_cleanup(async () => { | ||
element.inert = false; | ||
await cleanup(); | ||
}); | ||
} | ||
|
||
add_completion_callback(cleanup); | ||
|
||
promise_test(async function() { | ||
await setupTest(child, this); | ||
assert_false(window.find("wrapper")); | ||
assert_false(window.find("wrapper-child")); | ||
assert_true(window.find("fullscreen")); | ||
assert_false(window.find("child")); | ||
}, "Inner nodes with 'inert' attribute become inert anyways"); | ||
|
||
promise_test(async function() { | ||
await setupTest(fullscreen, this); | ||
assert_false(window.find("wrapper")); | ||
assert_false(window.find("wrapper-child")); | ||
assert_false(window.find("fullscreen")); | ||
assert_false(window.find("child")); | ||
}, "If the fullscreen element has the 'inert' attribute, everything becomes inert"); | ||
|
||
promise_test(async function() { | ||
await setupTest(wrapper, this); | ||
assert_false(window.find("wrapper")); | ||
assert_false(window.find("wrapper-child")); | ||
assert_true(window.find("fullscreen")); | ||
assert_true(window.find("child")); | ||
}, "If an ancestor of the fullscreen element has the 'inert' attribute, the fullscreen element escapes inertness"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8" /> | ||
<title>Interaction of 'inert' attribute with modal dialog</title> | ||
<link rel="author" title="Peng Zhou" href="mailto:[email protected]"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#inert"> | ||
<meta name="assert" content="Checks that a modal dialog escapes inertness from ancestors."> | ||
<div id="log"></div> | ||
<div id="wrapper"> | ||
find wrapper | ||
<dialog id="dialog"> | ||
find dialog | ||
<span id="child"> | ||
find child | ||
</span> | ||
</dialog> | ||
</div> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
function cleanup() { | ||
dialog.close(); | ||
getSelection().removeAllRanges(); | ||
} | ||
|
||
function setupTest(element, context) { | ||
element.inert = true; | ||
dialog.showModal(); | ||
context.add_cleanup(() => { | ||
element.inert = false; | ||
cleanup(); | ||
}); | ||
} | ||
|
||
setup(() => { | ||
dialog.showModal(); | ||
add_completion_callback(cleanup); | ||
}); | ||
|
||
test(function() { | ||
setupTest(child, this); | ||
assert_false(window.find("wrapper")); | ||
assert_true(window.find("dialog")); | ||
assert_false(window.find("child")); | ||
}, "Inner nodes with 'inert' attribute become inert anyways"); | ||
|
||
test(function() { | ||
setupTest(dialog, this); | ||
assert_false(window.find("wrapper")); | ||
assert_false(window.find("dialog")); | ||
assert_false(window.find("child")); | ||
}, "If the modal dialog has the 'inert' attribute, everything becomes inert"); | ||
|
||
test(function() { | ||
setupTest(wrapper, this); | ||
assert_false(window.find("wrapper")); | ||
assert_true(window.find("dialog")); | ||
assert_true(window.find("child")); | ||
}, "If an ancestor of the dialog has the 'inert' attribute, the dialog escapes inertness"); | ||
</script> |