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

Side by Side Diff: LayoutTests/fast/dom/shadow/event-path-closed-shadowroot.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: comment update 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!doctype html>
2 <script src="../../../resources/js-test.js"></script>
3 <script src="resources/shadow-dom.js"></script>
4 <body></body>
5 <script>
6 function prepareTree() {
7 document.body.appendChild(
8 createDOM('div', {id: 'host_open'},
9 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.
10 createDOM('div', {id: 'inner_open'},
11 createShadowRoot({mode: 'open'},
12 createDOM('span', {id: 'target_open', tabindex: '0'},
13 document.createTextNode('open')))))));
14
15 document.body.appendChild(
16 createDOM('div', {id: 'host_closed'},
17 createShadowRoot({mode: 'closed'},
18 createDOM('div', {id: 'inner_closed'},
19 createShadowRoot({mode: 'open'},
20 createDOM('span', {id: 'target_closed', tabindex: '0'},
21 document.createTextNode('closed')))))));
22 }
23
24 function clickHandler(e) {
25 eventPath = e.path;
26 }
27
28 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.
29
30 prepareTree();
31
32 var targetOpen = getNodeInTreeOfTrees('host_open/inner_open/target_open');
33 var targetClosed = getNodeInTreeOfTrees('host_closed/inner_closed/target_closed' );
34
35 targetOpen.addEventListener('click', clickHandler, false);
36 targetClosed.addEventListener('click', clickHandler, false);
37
38 debug("\nDispaching a click event on #target_open, listening on #target_open.");
39 var eventPath = null;
40 targetOpen.click();
41 // <span>, #shadow, <div>, #shadow, <div>, <body>, <html>, #document, window
42 shouldBe('eventPath.length', '9');
43 debug("\nevent.path for #target_open:");
44 debug(dumpNodeList(eventPath));
45
46 debug("\nDispaching a click event on #target_closed, listening on #target_closed .");
47 eventPath = null;
48 targetClosed.click();
49 // Same as open shadow root, as listener is in the closed shadow root.
50 // <span>, #shadow, <div>, #shadow, <div>, <body>, <html>, #document, window
51 shouldBe('eventPath.length', '9');
52 debug("\nevent.path for #target_closed:");
53 debug(dumpNodeList(eventPath));
54
55
56 targetOpen.removeEventListener('click', clickHandler, false);
57 targetClosed.removeEventListener('click', clickHandler, false);
58 document.body.addEventListener('click', clickHandler, false);
59
60 debug("\nDispaching a click event on #target_open, listening on document.body.") ;
61 var eventPath = null;
62 targetOpen.click();
63 // <span>, #shadow, <div>, #shadow, <div>, <body>, <html>, #document, window
64 shouldBe('eventPath.length', '9');
65 debug("\nevent.path for #target_open:");
66 debug(dumpNodeList(eventPath));
67
68 debug("\nDispaching a click event on #target_closed, listening on document.body. ");
69 eventPath = null;
70 targetClosed.click();
71 // For this test, <span> and closed shadow root are excluded from the open shado w case,
72 // thus 9 - 4 = 5.
73 // <div>, <body>, <html>, #document, window
74 shouldBe('eventPath.length', '5');
75 debug("\nevent.path for #target_closed:");
76 debug(dumpNodeList(eventPath));
77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698