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

[inert] Add WPTs for interaction of inert attribute with modal dialog #31668

Merged
merged 1 commit into from
Nov 25, 2021
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
56 changes: 56 additions & 0 deletions inert/inert-with-modal-dialog-001.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Interaction of 'inert' attribute with modal dialog</title>
<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#inert">
<meta name="assert" content="Checks that being part of a modal dialog does not protect a node from being marked inert by an 'inert' attribute.">
<div id="log"></div>
<div id="wrapper">
wrapper
<dialog id="dialog">
dialog
<span id="child">
child
</span>
</dialog>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup(() => {
dialog.showModal();
add_completion_callback(() => {
dialog.close();
getSelection().removeAllRanges();
});
});

function checkSelection(expectedText) {
const selection = getSelection();
selection.selectAllChildren(document.documentElement);
const actualText = selection.toString().trim();
assert_equals(actualText, expectedText);
}

test(function() {
checkSelection("dialog child");
}, "Modal dialog only marks outside nodes as inert");

test(function() {
child.inert = true;
this.add_cleanup(() => { child.inert = false; });
checkSelection("dialog");
}, "Inner nodes with 'inert' attribute become inert anyways");

test(function() {
dialog.inert = true;
this.add_cleanup(() => { dialog.inert = false; });
checkSelection("");
}, "If the modal dialog has the 'inert' attribute, everything becomes inert");

test(function() {
wrapper.inert = true;
this.add_cleanup(() => { wrapper.inert = false; });
checkSelection("");
}, "If an ancestor of the dialog has the 'inert' attribute, everything becomes inert");
</script>
56 changes: 56 additions & 0 deletions inert/inert-with-modal-dialog-002.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Interaction of 'inert' attribute with modal dialog, when the dialog is the root element</title>
<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#inert">
<meta name="assert" content="Checks that being part of a modal dialog does not protect a node from being marked inert by an 'inert' attribute.">
<div id="log"></div>
<dialog id="dialog">
dialog
<span id="child">
child
</span>
</dialog>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const dialog = document.getElementById("dialog");
const root = document.documentElement;

setup(() => {
root.remove();
document.append(dialog);
dialog.showModal();
add_completion_callback(() => {
getSelection().removeAllRanges();
});
});

function checkSelection(expectedText) {
const selection = getSelection();
selection.selectAllChildren(document.documentElement);
const actualText = selection.toString().trim();
assert_equals(actualText, expectedText);
}

test(function() {
checkSelection("dialog child");
}, "Modal dialog only marks outside nodes as inert");

test(function() {
child.inert = true;
this.add_cleanup(() => { child.inert = false; });
checkSelection("dialog");
}, "Inner nodes with 'inert' attribute become inert anyways");

test(function() {
dialog.inert = true;
this.add_cleanup(() => { dialog.inert = false; });
checkSelection("");
}, "If the modal dialog has the 'inert' attribute, everything becomes inert");

// Ideally this would happen in a completion callback, but then it would
// be too late: the results would have been shown inside the dialog.
dialog.remove();
document.append(root);
</script>