Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: LayoutTests/fast/dom/shadow/event-path-closed-shadowroot2.html

Issue 1305733002: Fix for calculation of event.path for closed mode shadow root (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: isUnclosedTreeOf() Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/shadow/event-path-closed-shadowroot2.html
diff --git a/LayoutTests/fast/dom/shadow/event-path-closed-shadowroot2.html b/LayoutTests/fast/dom/shadow/event-path-closed-shadowroot2.html
new file mode 100644
index 0000000000000000000000000000000000000000..2fdba678e9426b838fa972b4cda96c4f810cd353
--- /dev/null
+++ b/LayoutTests/fast/dom/shadow/event-path-closed-shadowroot2.html
@@ -0,0 +1,54 @@
+<!doctype html>
+<script src="../../../resources/js-test.js"></script>
+<script src="resources/shadow-dom.js"></script>
+<body></body>
+<script>
+function prepareTree() {
+ // Note: #target will be distributed to furthest <content>.
+ document.body.appendChild(
+ createDOM('div', {id: 'host_closed'},
+ createShadowRoot({mode: 'closed'},
+ createDOM('div', {id: 'div1_open'},
+ createDOM('content', {id: 'c1'}),
+ createShadowRoot({mode: 'open'},
+ createDOM('content', {id: 'c2'})))),
+ createDOM('div', {id: 'host_open'},
+ createShadowRoot({mode: 'open'},
+ createDOM('div', {id: 'div2_closed'},
+ createShadowRoot({mode: 'closed'},
+ createDOM('div', {id: 'div3_open'},
+ createShadowRoot({mode: 'open'},
+ createDOM('div', {id: 'target'})))))))));
+}
+
+debug('Event.path should include only unclosed nodes.');
+
+prepareTree();
+
+var target = getNodeInTreeOfTrees('host_open/div2_closed/div3_open/target');
+
+debug('The full event path should be (length=12):\n' +
+ 'div#target, #shadow-root (open), div#div3_open, #shadow-root (closed),\n' +
+ 'div#div2_closed, #shadow-root (open), div#host_open, div#host_closed,\n' +
+ 'body, html, #document, window\n');
+
+debug('On #host_closed, #host_open, and #div2_closed,\n' +
+ 'div#target, #shadow-root (open), div#div3_open, #shadow-root (closed)\n' +
+ 'will be trimmed (length=8).\n');
+
+['host_closed', 'host_open', 'host_open/div2_closed', 'host_open/div2_closed/div3_open', 'host_open/div2_closed/div3_open/target'].forEach(function(nodePath) {
+ var node = getNodeInTreeOfTrees(nodePath);
+
+ var eventPath;
+ var clickHandler = function(e) { eventPath = e.path; };
+ node.addEventListener('click', clickHandler, false);
+
+ debug('\nDispaching a click event on #target, listening on #' + node.id + '.');
+ eventPath = null;
+ target.click();
+ debug('Got event.path for #' + node.id + ':');
+ debug(dumpNodeList(eventPath));
+
+ node.removeEventListener('click', clickHandler, false);
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698