- Revision
- 285791
- Author
- n...@apple.com
- Date
- 2021-11-14 10:47:32 -0800 (Sun, 14 Nov 2021)
Log Message
Modal dialogs should make the root element unfocusable
https://bugs.webkit.org/show_bug.cgi?id=233099
Reviewed by Simon Fraser.
>From https://html.spec.whatwg.org/multipage/interaction.html#inert,
> A Document document is blocked by a modal dialog subject if subject is
> the topmost dialog element in document's top layer. While document is
> so blocked, every node that is connected to document, with the
> exception of the subject element and its shadow-including descendants,
> must be marked inert.
RenderStyle::effectiveInert() already matches this definition, Node::deprecatedIsInert() does not.
Main reason the removed check was there is to prevent the whole document from being inert to hit-testing, but with the RenderStyle
approach, we instead override effectiveInert to false for the modal dialog. Removing this check for focus is absolutely fine
however, since focusability isn't inherited (Node::deprecatedIsInert is only used for focus).
Tests added by this Chromium WPT: https://github.com/web-platform-tests/wpt/commit/0457111e7109ec3d9e575aa421b96d8c36ce2ae8
LayoutTests/imported/w3c:
* web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt:
* web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html:
Source/WebCore:
* dom/Node.cpp:
(WebCore::Node::deprecatedIsInert const):
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285790 => 285791)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-14 18:38:45 UTC (rev 285790)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-14 18:47:32 UTC (rev 285791)
@@ -1,3 +1,29 @@
+2021-11-14 Tim Nguyen <n...@apple.com>
+
+ Modal dialogs should make the root element unfocusable
+ https://bugs.webkit.org/show_bug.cgi?id=233099
+
+ Reviewed by Simon Fraser.
+
+ From https://html.spec.whatwg.org/multipage/interaction.html#inert,
+
+ > A Document document is blocked by a modal dialog subject if subject is
+ > the topmost dialog element in document's top layer. While document is
+ > so blocked, every node that is connected to document, with the
+ > exception of the subject element and its shadow-including descendants,
+ > must be marked inert.
+
+ RenderStyle::effectiveInert() already matches this definition, Node::deprecatedIsInert() does not.
+
+ Main reason the removed check was there is to prevent the whole document from being inert to hit-testing, but with the RenderStyle
+ approach, we instead override effectiveInert to false for the modal dialog. Removing this check for focus is absolutely fine
+ however, since focusability isn't inherited (Node::deprecatedIsInert is only used for focus).
+
+ Tests added by this Chromium WPT: https://github.com/web-platform-tests/wpt/commit/0457111e7109ec3d9e575aa421b96d8c36ce2ae8
+
+ * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt:
+ * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html:
+
2021-11-12 Ryan Haddad <ryanhad...@apple.com>
Unreviewed, reverting r285583.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt (285790 => 285791)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt 2021-11-14 18:38:45 UTC (rev 285790)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt 2021-11-14 18:47:32 UTC (rev 285791)
@@ -1,8 +1,21 @@
-I get focusI don't get focus.
I'm editable
I'm tabindexed.
Link
-PASS Test that inert nodes are not focusable.
+PASS #html is not focusable
+PASS #body is not focusable
+PASS #top-dialog is focusable
+PASS #top-dialog-button is focusable
+PASS #bottom-dialog is not focusable
+PASS #bottom-dialog-button is not focusable
+PASS #container is not focusable
+PASS #text is not focusable
+PASS #datetime is not focusable
+PASS #color is not focusable
+PASS #select is not focusable
+PASS #optgroup is not focusable
+PASS #option is not focusable
+PASS #contenteditable-div is not focusable
+PASS #tabindex-span is not focusable
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html (285790 => 285791)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html 2021-11-14 18:38:45 UTC (rev 285790)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html 2021-11-14 18:47:32 UTC (rev 285791)
@@ -1,6 +1,8 @@
<!DOCTYPE html>
-<html>
+<html id="html" tabindex="1">
<head>
+<link rel="help" href=""
+<meta name="assert" content="Checks that, when opening modal dialogs, inert nodes are not focusable.">
<script src=""
<script src=""
</head>
@@ -26,11 +28,17 @@
// The test passses if only the topmost dialog and its button are focusable.
function testFocus(element, expectFocus) {
- var focusedElement = null;
- element.addEventListener('focus', function() { focusedElement = element; }, false);
- element.focus();
- var theElement = element;
- assert_equals(focusedElement === theElement, expectFocus, element.id);
+ test(function() {
+ var focusedElement = null;
+ element.addEventListener('focus', function() { focusedElement = element; }, false);
+ element.focus();
+ var theElement = element;
+ if (expectFocus) {
+ assert_equals(focusedElement, theElement);
+ } else {
+ assert_not_equals(focusedElement, theElement);
+ }
+ }, `#${CSS.escape(element.id)} is ${expectFocus ? "" : "not "} focusable`);
}
function testTree(element, expectFocus) {
@@ -41,18 +49,22 @@
testTree(childNodes[i], expectFocus);
}
-test(function() {
- var bottomDialog = document.getElementById('bottom-dialog');
+var bottomDialog = document.getElementById('bottom-dialog');
+var topDialog = document.getElementById('top-dialog');
+setup(function() {
bottomDialog.showModal();
-
- var topDialog = document.getElementById('top-dialog');
topDialog.showModal();
+ add_completion_callback(function() {
+ topDialog.close();
+ bottomDialog.close();
+ });
+});
- testFocus(document.body, false);
- testTree(topDialog, true);
- testTree(bottomDialog, false);
- testTree(document.getElementById('container'), false);
-}, "Test that inert nodes are not focusable.");
+testFocus(document.documentElement, false);
+testFocus(document.body, false);
+testTree(topDialog, true);
+testTree(bottomDialog, false);
+testTree(document.getElementById('container'), false);
</script>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (285790 => 285791)
--- trunk/Source/WebCore/ChangeLog 2021-11-14 18:38:45 UTC (rev 285790)
+++ trunk/Source/WebCore/ChangeLog 2021-11-14 18:47:32 UTC (rev 285791)
@@ -1,3 +1,29 @@
+2021-11-14 Tim Nguyen <n...@apple.com>
+
+ Modal dialogs should make the root element unfocusable
+ https://bugs.webkit.org/show_bug.cgi?id=233099
+
+ Reviewed by Simon Fraser.
+
+ From https://html.spec.whatwg.org/multipage/interaction.html#inert,
+
+ > A Document document is blocked by a modal dialog subject if subject is
+ > the topmost dialog element in document's top layer. While document is
+ > so blocked, every node that is connected to document, with the
+ > exception of the subject element and its shadow-including descendants,
+ > must be marked inert.
+
+ RenderStyle::effectiveInert() already matches this definition, Node::deprecatedIsInert() does not.
+
+ Main reason the removed check was there is to prevent the whole document from being inert to hit-testing, but with the RenderStyle
+ approach, we instead override effectiveInert to false for the modal dialog. Removing this check for focus is absolutely fine
+ however, since focusability isn't inherited (Node::deprecatedIsInert is only used for focus).
+
+ Tests added by this Chromium WPT: https://github.com/web-platform-tests/wpt/commit/0457111e7109ec3d9e575aa421b96d8c36ce2ae8
+
+ * dom/Node.cpp:
+ (WebCore::Node::deprecatedIsInert const):
+
2021-11-14 Simon Fraser <simon.fra...@apple.com>
Attach IOHIDEvent timestamps to wheel events
Modified: trunk/Source/WebCore/dom/Node.cpp (285790 => 285791)
--- trunk/Source/WebCore/dom/Node.cpp 2021-11-14 18:38:45 UTC (rev 285790)
+++ trunk/Source/WebCore/dom/Node.cpp 2021-11-14 18:47:32 UTC (rev 285791)
@@ -2628,7 +2628,7 @@
if (!isConnected())
return true;
- if (this != &document() && this != document().documentElement()) {
+ if (this != &document()) {
Node* activeModalDialog = document().activeModalDialog();
if (activeModalDialog && !activeModalDialog->containsIncludingShadowDOM(this))
return true;