summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortdanderson@chromium.org <tdanderson@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-01-14 18:31:46 +0000
committertdanderson@chromium.org <tdanderson@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-01-14 18:31:46 +0000
commitc19c0bf05fae49b0ca08ae592c967e230b9cd74a (patch)
tree3eed67641404d5beaed8804969058785fc12aae5
parent836a58e0b0a8b023c06f1fee46907b3fbc6b22a4 (diff)
downloadchromium_src-c19c0bf05fae49b0ca08ae592c967e230b9cd74a.zip
chromium_src-c19c0bf05fae49b0ca08ae592c967e230b9cd74a.tar.gz
chromium_src-c19c0bf05fae49b0ca08ae592c967e230b9cd74a.tar.bz2
Revert of Make ancestors of modal <dialog> inert (https://codereview.chromium.org/133393002/)
Reason for revert: This patch is the most probable cause of the failing content_browsertests: AccessibilityModalDialogInIframeOpened AccessibilityModalDialogOpened AccessibilityModalDialogStack See: http://build.chromium.org/p/chromium.webkit/builders/Win7%20Tests/builds/529 http://build.chromium.org/p/chromium.webkit/builders/Win7%20%28dbg%29/builds/13227 http://build.chromium.org/p/chromium.webkit/builders/Mac10.6%20Tests/builds/22361 http://build.chromium.org/p/chromium.webkit/builders/Mac10.8%20Tests/builds/5388 I could not reach the patch author on IRC due to the time zone difference. Original issue's description: > Make ancestors of modal <dialog> inert > > As per spec change: http://html5.org/r/8343 > > Now, document.body is also inert. Previously events that > "skipped" an inert node were fired on document.body; now, > they are fired on document. > > Test: modal-dialog-ancestor-is-inert.html > Also, other tests cover some of this behavior and have > expectations updated. > > BUG=329407 > > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=165040 TBR=esprehn@chromium.org,falken@chromium.org NOTREECHECKS=true NOTRY=true BUG=329407 Review URL: https://codereview.chromium.org/138183003 git-svn-id: svn://svn.chromium.org/blink/trunk@165086 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--third_party/WebKit/LayoutTests/dialog/inert-node-is-not-highlighted-expected.html3
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-inlines.html6
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable.html6
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert-expected.txt19
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert.html111
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events-expected.txt8
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html44
-rw-r--r--third_party/WebKit/Source/core/dom/Node.cpp2
9 files changed, 40 insertions, 163 deletions
diff --git a/third_party/WebKit/LayoutTests/dialog/inert-node-is-not-highlighted-expected.html b/third_party/WebKit/LayoutTests/dialog/inert-node-is-not-highlighted-expected.html
index 3aaeb5f..64796e7 100644
--- a/third_party/WebKit/LayoutTests/dialog/inert-node-is-not-highlighted-expected.html
+++ b/third_party/WebKit/LayoutTests/dialog/inert-node-is-not-highlighted-expected.html
@@ -24,8 +24,7 @@ none (crbug.com/147490).</p>
<script>
dialog = document.querySelector('dialog');
dialog.show();
-selectable = document.querySelector('#selectable');
-window.getSelection().selectAllChildren(selectable);
+document.execCommand('SelectAll');
</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-inlines.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-inlines.html
index 8d95ae6..2b9c920 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-inlines.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-inlines.html
@@ -53,8 +53,8 @@ inertElements.forEach(function(id) {
element.addEventListener('mousemove', eventFiredOnInertElement);
});
-document.addEventListener('click', function(e) {
- document.firedOn = true;
+document.body.addEventListener('click', function(e) {
+ document.body.firedOn = true;
});
document.getElementById('dialog-parent').addEventListener('click', function(e) {
@@ -63,7 +63,7 @@ document.getElementById('dialog-parent').addEventListener('click', function(e) {
document.querySelector('dialog').showModal();
inertElements.forEach(function(id) {
- expectedTarget = document;
+ expectedTarget = document.body;
if (id == 'dialog-sibling')
expectedTarget = document.getElementById('dialog-parent')
element = document.getElementById(id);
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable-expected.txt
index 0151288..71d1f6e 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable-expected.txt
@@ -1,9 +1,9 @@
-Test that inert nodes are not focusable. The test passses if only the topmost dialog and its button are focusable.
+Test that inert nodes are not focusable. The test passses if only the document body and the topmost dialog and its button are focusable.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS "body"; focusedElement === theElement is false
+PASS "body"; focusedElement === theElement is true
PASS "top-dialog"; focusedElement === theElement is true
PASS "top-dialog-button"; focusedElement === theElement is true
PASS "bottom-dialog"; focusedElement === theElement is false
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable.html
index 631e6d4..66da1580 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/inert-node-is-unfocusable.html
@@ -21,8 +21,8 @@
<a id="anchor" href="">Link</a>
</div>
<script>
-description('Test that inert nodes are not focusable. The test passses if only the ' +
- 'topmost dialog and its button are focusable.');
+description('Test that inert nodes are not focusable. The test passses if only the document body ' +
+ 'and the topmost dialog and its button are focusable.');
function testFocus(element, expectFocus) {
focusedElement = null;
@@ -47,7 +47,7 @@ bottomDialog.showModal();
var topDialog = document.getElementById('top-dialog');
topDialog.showModal();
-testFocus(document.body, false);
+testFocus(document.body, true);
testTree(topDialog, true);
testTree(bottomDialog, false);
testTree(document.getElementById('container'), false);
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert-expected.txt
deleted file mode 100644
index 212dbda..0000000
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert-expected.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-Test that ancestors of modal <dialog> are inert. To test manually, click the left box. There should be no change. Then click the right box. If both boxes turn green, the test passes.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Clicking on ancestor
-PASS handledEvent.document is true
-PASS handledEvent.body is false
-PASS handledEvent.dialog is false
-PASS handledEvent.div is false
-Clicking on dialog
-PASS handledEvent.document is true
-PASS handledEvent.body is true
-PASS handledEvent.dialog is true
-PASS handledEvent.div is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert.html
deleted file mode 100644
index 554664c..0000000
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert.html
+++ /dev/null
@@ -1,111 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<style>
-#ancestor {
- position: absolute;
- height: 50px;
- width: 50px;
- top: 200px;
- left: 100px;
- border: 1px solid;
-}
-
-dialog {
- height: 50px;
- width: 50px;
- top: 200px;
- left: 200px;
- margin: 0;
-}
-
-dialog::backdrop {
- display: none;
-}
-</style>
-<script src="../../../resources/js-test.js"></script>
-</head>
-<body>
-<div id="ancestor">
- <dialog></dialog>
-</div>
-<script>
-function clickOn(element)
-{
- var rect = element.getBoundingClientRect();
- eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
- eventSender.mouseDown();
- eventSender.mouseUp();
-}
-
-// For manual testing, indicate success only if automatic testing would also
-// print success for all ancestor nodes.
-function turnDivGreenOnSuccess()
-{
- if (handledEvent['document'] && handledEvent['body'] && handledEvent['div'])
- div.style.backgroundColor = 'green';
-}
-
-description('Test that ancestors of modal &lt;dialog&gt; are inert. To test manually, ' +
- 'click the left box. There should be no change. Then click the right box. ' +
- 'If both boxes turn green, the test passes.');
-div = document.querySelector('#ancestor');
-dialog = document.querySelector('dialog');
-dialog.showModal();
-
-handledEvent = {};
-document.addEventListener('click', function(event) {
- handledEvent['document'] = true;
- turnDivGreenOnSuccess();
-});
-
-document.body.addEventListener('click', function(event) {
- handledEvent['body'] = true;
- turnDivGreenOnSuccess();
- // body should get a event only via bubbling.
- if (event.target != dialog) {
- testFailed('body was targeted for an click event');
- div.style.backgroundColor = 'red';
- }
-});
-
-div.addEventListener('click', function(event) {
- handledEvent['div'] = true;
- turnDivGreenOnSuccess();
- // div should get a event only via bubbling.
- if (event.target != dialog) {
- testFailed('div was targeted for an click event');
- div.style.backgroundColor = 'red';
- }
-});
-
-dialog.addEventListener('click', function(event) {
- handledEvent['dialog'] = true;
- dialog.style.backgroundColor = 'green';
- if (event.target != dialog) {
- testFailed('dialog was not targeted for a click event');
- dialog.style.backgroundColor = 'red';
- }
-});
-
-if (window.eventSender) {
- nodes = [ 'document', 'body', 'div', 'dialog' ];
- nodes.map(function(node) { handledEvent[node] = false; });
- debug('Clicking on ancestor');
- clickOn(div);
- shouldBeTrue('handledEvent.document');
- shouldBeFalse('handledEvent.body');
- shouldBeFalse('handledEvent.dialog');
- shouldBeFalse('handledEvent.div');
- handledEvent.document = false;
-
- debug('Clicking on dialog');
- clickOn(dialog);
- shouldBeTrue('handledEvent.document');
- shouldBeTrue('handledEvent.body');
- shouldBeTrue('handledEvent.dialog');
- shouldBeTrue('handledEvent.div');
-}
-</script>
-</body>
-</html>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events-expected.txt
index 23785d3..6268bb2 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events-expected.txt
@@ -4,11 +4,11 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Clicking on inert box
-PASS inertDivHandledEvent is false
-PASS Object.keys(handledEvents.document).length is expectedEventCountForDocument
+PASS inertDiv.firedOn is false
+PASS Object.keys(body.firedOnEvents).length is events.length
Clicking on non-inert box
-PASS inertDivHandledEvent is false
-PASS Object.keys(handledEvents.dialogDiv).length is events.length
+PASS inertDiv.firedOn is false
+PASS Object.keys(dialogDiv.firedOnEvents).length is events.length
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html
index a725e10..2d1ec44 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html
@@ -40,8 +40,17 @@ function clickOn(element)
{
if (!window.eventSender)
return;
- var rect = element.getBoundingClientRect();
- eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
+
+ var absoluteTop = 0;
+ var absoluteLeft = 0;
+ for (var parentNode = element; parentNode; parentNode = parentNode.offsetParent) {
+ absoluteLeft += parentNode.offsetLeft;
+ absoluteTop += parentNode.offsetTop;
+ }
+
+ var x = absoluteLeft + element.offsetWidth / 2;
+ var y = absoluteTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
eventSender.mouseMoveTo(0, 0);
@@ -52,46 +61,45 @@ if (window.testRunner)
dialog.showModal();
-inertDivHandledEvent = false;
inertDiv = document.getElementById('inert-div');
+inertDiv.firedOn = false;
eventFiredOnInertNode = function(event) {
- inertDivHandledEvent = true;
+ inertDiv.firedOn = true;
inertDiv.style.backgroundColor = 'red';
};
events = ['mousedown', 'mouseup', 'click', 'mousemove', 'mouseover', 'mouseout'];
dialogDiv = document.getElementById('dialog-div');
-handledEvents = {};
-handledEvents.dialogDiv = {};
+dialogDiv.firedOnEvents = {};
eventFiredOnDialog = function(event) {
- handledEvents.dialogDiv[event.type] = true;
- if (Object.keys(handledEvents.dialogDiv).length == events.length)
+ dialogDiv.firedOnEvents[event.type] = true;
+ if (Object.keys(dialogDiv.firedOnEvents).length == events.length)
dialogDiv.style.backgroundColor = 'green';
};
-handledEvents.document = {};
-expectedEventCountForDocument = events.length - 1; // document won't get 'mouseout'
-eventFiredOnDocument = function(event) {
- handledEvents.document[event.type] = true;
- if (Object.keys(handledEvents.document).length == document.expectedEventCount && !inertDivHandledEvent)
+body = document.body;
+body.firedOnEvents = {};
+eventFiredOnBody = function(event) {
+ body.firedOnEvents[event.type] = true;
+ if (Object.keys(body.firedOnEvents).length == events.length && !inertDiv.firedOn)
inertDiv.style.backgroundColor = 'green';
};
for (var i = 0; i < events.length; ++i) {
inertDiv.addEventListener(events[i], eventFiredOnInertNode);
dialogDiv.addEventListener(events[i], eventFiredOnDialog);
- document.addEventListener(events[i], eventFiredOnDocument);
+ document.body.addEventListener(events[i], eventFiredOnBody);
}
debug('Clicking on inert box');
clickOn(inertDiv);
-shouldBeFalse('inertDivHandledEvent');
-shouldBe('Object.keys(handledEvents.document).length', 'expectedEventCountForDocument');
+shouldBeFalse('inertDiv.firedOn');
+shouldBe('Object.keys(body.firedOnEvents).length', 'events.length');
debug('Clicking on non-inert box');
clickOn(dialogDiv);
-shouldBeFalse('inertDivHandledEvent');
-shouldBe('Object.keys(handledEvents.dialogDiv).length', 'events.length');
+shouldBeFalse('inertDiv.firedOn');
+shouldBe('Object.keys(dialogDiv.firedOnEvents).length', 'events.length');
</script>
</body>
</html>
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp
index 5e1deff..2c1dc4c 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -792,7 +792,7 @@ bool Node::shouldHaveFocusAppearance() const
bool Node::isInert() const
{
const HTMLDialogElement* dialog = document().activeModalDialog();
- if (dialog && this != document() && !dialog->containsIncludingShadowDOM(this))
+ if (dialog && !containsIncludingShadowDOM(dialog) && !dialog->containsIncludingShadowDOM(this))
return true;
return document().ownerElement() && document().ownerElement()->isInert();
}