Index: LayoutTests/fast/dom/shadow/event-path-closed-shadowroot.html |
diff --git a/LayoutTests/fast/dom/shadow/event-path-closed-shadowroot.html b/LayoutTests/fast/dom/shadow/event-path-closed-shadowroot.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..14cc8de6c2786af501e9289a1a0e9ef7d98247ab |
--- /dev/null |
+++ b/LayoutTests/fast/dom/shadow/event-path-closed-shadowroot.html |
@@ -0,0 +1,77 @@ |
+<!doctype html> |
+<script src="../../../resources/js-test.js"></script> |
+<script src="resources/shadow-dom.js"></script> |
+<body></body> |
+<script> |
+function prepareTree() { |
+ document.body.appendChild( |
+ createDOM('div', {id: 'host_open'}, |
+ createShadowRoot({mode: 'open'}, |
hayato
2015/08/25 01:34:20
Could you add an id attribute to Shadow Roots so t
kochi
2015/08/25 02:18:30
Done.
|
+ createDOM('div', {id: 'inner_open'}, |
+ createShadowRoot({mode: 'open'}, |
+ createDOM('span', {id: 'target_open', tabindex: '0'}, |
+ document.createTextNode('open'))))))); |
+ |
+ document.body.appendChild( |
+ createDOM('div', {id: 'host_closed'}, |
+ createShadowRoot({mode: 'closed'}, |
+ createDOM('div', {id: 'inner_closed'}, |
+ createShadowRoot({mode: 'open'}, |
+ createDOM('span', {id: 'target_closed', tabindex: '0'}, |
+ document.createTextNode('closed'))))))); |
+} |
+ |
+function clickHandler(e) { |
+ eventPath = e.path; |
+} |
+ |
+debug('Event.path should include only unclosed elements.'); |
hayato
2015/08/25 01:34:20
s/elements/nodes/
kochi
2015/08/25 02:18:30
Done.
|
+ |
+prepareTree(); |
+ |
+var targetOpen = getNodeInTreeOfTrees('host_open/inner_open/target_open'); |
+var targetClosed = getNodeInTreeOfTrees('host_closed/inner_closed/target_closed'); |
+ |
+targetOpen.addEventListener('click', clickHandler, false); |
+targetClosed.addEventListener('click', clickHandler, false); |
+ |
+debug("\nDispaching a click event on #target_open, listening on #target_open."); |
+var eventPath = null; |
+targetOpen.click(); |
+// <span>, #shadow, <div>, #shadow, <div>, <body>, <html>, #document, window |
+shouldBe('eventPath.length', '9'); |
+debug("\nevent.path for #target_open:"); |
+debug(dumpNodeList(eventPath)); |
+ |
+debug("\nDispaching a click event on #target_closed, listening on #target_closed."); |
+eventPath = null; |
+targetClosed.click(); |
+// Same as open shadow root, as listener is in the closed shadow root. |
+// <span>, #shadow, <div>, #shadow, <div>, <body>, <html>, #document, window |
+shouldBe('eventPath.length', '9'); |
+debug("\nevent.path for #target_closed:"); |
+debug(dumpNodeList(eventPath)); |
+ |
+ |
+targetOpen.removeEventListener('click', clickHandler, false); |
+targetClosed.removeEventListener('click', clickHandler, false); |
+document.body.addEventListener('click', clickHandler, false); |
+ |
+debug("\nDispaching a click event on #target_open, listening on document.body."); |
+var eventPath = null; |
+targetOpen.click(); |
+// <span>, #shadow, <div>, #shadow, <div>, <body>, <html>, #document, window |
+shouldBe('eventPath.length', '9'); |
+debug("\nevent.path for #target_open:"); |
+debug(dumpNodeList(eventPath)); |
+ |
+debug("\nDispaching a click event on #target_closed, listening on document.body."); |
+eventPath = null; |
+targetClosed.click(); |
+// For this test, <span> and closed shadow root are excluded from the open shadow case, |
+// thus 9 - 4 = 5. |
+// <div>, <body>, <html>, #document, window |
+shouldBe('eventPath.length', '5'); |
+debug("\nevent.path for #target_closed:"); |
+debug(dumpNodeList(eventPath)); |
+</script> |