OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 <script src="resources/shadow-dom.js"></script> | 5 <script src="resources/shadow-dom.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <p id="description"></p> | 8 <p id="description"></p> |
9 <div id="sandbox"></div> | 9 <div id="sandbox"></div> |
10 <pre id="console"></pre> | 10 <pre id="console"></pre> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 eventRecords[eventType].push(eventString); | 49 eventRecords[eventType].push(eventString); |
50 } | 50 } |
51 | 51 |
52 debug('None of the events should be stopped at a Shadow boundary if created by u
sers.'); | 52 debug('None of the events should be stopped at a Shadow boundary if created by u
sers.'); |
53 | 53 |
54 var events = ['abort', 'select', 'change', 'reset', 'resize', 'scroll', 'selects
tart', 'load', 'click']; | 54 var events = ['abort', 'select', 'change', 'reset', 'resize', 'scroll', 'selects
tart', 'load', 'click']; |
55 | 55 |
56 function addEventListeners(nodes) | 56 function addEventListeners(nodes) |
57 { | 57 { |
58 for (var i = 0; i < nodes.length; ++i) { | 58 for (var i = 0; i < nodes.length; ++i) { |
59 var node = getNodeInTreeOfTrees(nodes[i]); | 59 var node = getNodeInComposedTree(nodes[i]); |
60 for (var j = 0; j < events.length; ++j) | 60 for (var j = 0; j < events.length; ++j) |
61 node.addEventListener(events[j], recordEvent, false); | 61 node.addEventListener(events[j], recordEvent, false); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 function testEventsShouldNotBeStoppedAtShadowBoundary() | 65 function testEventsShouldNotBeStoppedAtShadowBoundary() |
66 { | 66 { |
67 var sandbox = document.getElementById('sandbox'); | 67 var sandbox = document.getElementById('sandbox'); |
68 sandbox.innerHTML = ''; | 68 sandbox.innerHTML = ''; |
69 sandbox.appendChild( | 69 sandbox.appendChild( |
70 createDOM('div', {'id': 'top'}, | 70 createDOM('div', {'id': 'top'}, |
71 createDOM('div', {'id': 'host'}, | 71 createDOM('div', {'id': 'host'}, |
72 createShadowRoot( | 72 createShadowRoot( |
73 createDOM('div', {'id': 'parent-of-target'}, | 73 createDOM('div', {'id': 'parent-of-target'}, |
74 createDOM('div', {'id': 'target'})), | 74 createDOM('div', {'id': 'target'})), |
75 createDOM('div', {'id': 'parent-of-content'}, | 75 createDOM('div', {'id': 'parent-of-content'}, |
76 createDOM('content', {'id': 'content'}
))), | 76 createDOM('content', {'id': 'content'}
))), |
77 createDOM('div', {'id': 'distributed-child'})))); | 77 createDOM('div', {'id': 'distributed-child'})))); |
78 document.body.offsetLeft; | 78 document.body.offsetLeft; |
79 | 79 |
80 addEventListeners(['top', 'host', 'host/parent-of-target', 'host/target', 'h
ost/parent-of-content', 'host/content', 'distributed-child']); | 80 addEventListeners(['top', 'host', 'host/parent-of-target', 'host/target', 'h
ost/parent-of-content', 'host/content', 'distributed-child']); |
81 | 81 |
82 for (var i = 0; i < events.length; ++i) { | 82 for (var i = 0; i < events.length; ++i) { |
83 eventRecords = {}; | 83 eventRecords = {}; |
84 var event = document.createEvent('UIEvent'); | 84 var event = document.createEvent('UIEvent'); |
85 event.initEvent(events[i], true, false); | 85 event.initEvent(events[i], true, false); |
86 getNodeInTreeOfTrees('host/target').dispatchEvent(event); | 86 getNodeInComposedTree('host/target').dispatchEvent(event); |
87 dumpDispatchedEvent(events[i]); | 87 dumpDispatchedEvent(events[i]); |
88 } | 88 } |
89 | 89 |
90 } | 90 } |
91 | 91 |
92 function testEventsFiredOnDistributedNodesShouldNotBeStoppedAtShadowBoundary() | 92 function testEventsFiredOnDistributedNodesShouldNotBeStoppedAtShadowBoundary() |
93 { | 93 { |
94 var sandbox = document.getElementById('sandbox'); | 94 var sandbox = document.getElementById('sandbox'); |
95 sandbox.innerHTML = ''; | 95 sandbox.innerHTML = ''; |
96 sandbox.appendChild( | 96 sandbox.appendChild( |
97 createDOM('div', {'id': 'host1'}, | 97 createDOM('div', {'id': 'host1'}, |
98 createShadowRoot( | 98 createShadowRoot( |
99 createDOM('div', {'id': 'host2'}, | 99 createDOM('div', {'id': 'host2'}, |
100 createShadowRoot( | 100 createShadowRoot( |
101 createDOM('div', {'id': 'parent-of-content'}
, | 101 createDOM('div', {'id': 'parent-of-content'}
, |
102 createDOM('content', {'id': 'conte
nt'}))), | 102 createDOM('content', {'id': 'conte
nt'}))), |
103 createDOM('div', {'id': 'distributed-child'}))))
); | 103 createDOM('div', {'id': 'distributed-child'}))))
); |
104 document.body.offsetLeft; | 104 document.body.offsetLeft; |
105 | 105 |
106 addEventListeners(['host1', 'host1/host2', 'host1/host2/parent-of-content',
'host1/host2/content', 'host1/distributed-child']); | 106 addEventListeners(['host1', 'host1/host2', 'host1/host2/parent-of-content',
'host1/host2/content', 'host1/distributed-child']); |
107 | 107 |
108 debug('\nAn event fired on a distributed child should not be stopped at the
shadow boundary of its host (host2), but should be stopped at the nearest shadow
boundary (host1).'); | 108 debug('\nAn event fired on a distributed child should not be stopped at the
shadow boundary of its host (host2), but should be stopped at the nearest shadow
boundary (host1).'); |
109 eventRecords = {}; | 109 eventRecords = {}; |
110 var event = document.createEvent('UIEvent'); | 110 var event = document.createEvent('UIEvent'); |
111 event.initEvent('selectstart', true, false); | 111 event.initEvent('selectstart', true, false); |
112 getNodeInTreeOfTrees('host1/distributed-child').dispatchEvent(event); | 112 getNodeInComposedTree('host1/distributed-child').dispatchEvent(event); |
113 dumpDispatchedEvent('selectstart'); | 113 dumpDispatchedEvent('selectstart'); |
114 } | 114 } |
115 | 115 |
116 function testEventsInMultipleShadowTrees() | 116 function testEventsInMultipleShadowTrees() |
117 { | 117 { |
118 debug("\nAn event is dispatched on a node in an older shadow tree. The older
and the younger shadow root should receive the event, however, the shadow host
shouldn't"); | 118 debug("\nAn event is dispatched on a node in an older shadow tree. The older
and the younger shadow root should receive the event, however, the shadow host
shouldn't"); |
119 | 119 |
120 var sandbox = document.getElementById('sandbox'); | 120 var sandbox = document.getElementById('sandbox'); |
121 sandbox.innerHTML = ''; | 121 sandbox.innerHTML = ''; |
122 sandbox.appendChild( | 122 sandbox.appendChild( |
123 createDOM('div', {'id': 'shadow-host'}, | 123 createDOM('div', {'id': 'shadow-host'}, |
124 createShadowRoot({'id': 'older-shadow-root'}, | 124 createShadowRoot({'id': 'older-shadow-root'}, |
125 createDOM('div', {'id': 'target'})), | 125 createDOM('div', {'id': 'target'})), |
126 createShadowRoot({'id': 'younger-shadow-root'}, | 126 createShadowRoot({'id': 'younger-shadow-root'}, |
127 createDOM('shadow', {'id': 'shadow-insertion-point'}))))
; | 127 createDOM('shadow', {'id': 'shadow-insertion-point'}))))
; |
128 document.body.offsetLeft; | 128 document.body.offsetLeft; |
129 | 129 |
130 addEventListeners(['shadow-host', 'shadow-host/', 'shadow-host/target', 'sha
dow-host//', 'shadow-host//shadow-insertion-point']); | 130 addEventListeners(['shadow-host', 'shadow-host/', 'shadow-host/target', 'sha
dow-host//', 'shadow-host//shadow-insertion-point']); |
131 | 131 |
132 eventRecords = {}; | 132 eventRecords = {}; |
133 var event = document.createEvent('UIEvent'); | 133 var event = document.createEvent('UIEvent'); |
134 event.initEvent('selectstart', true, false); | 134 event.initEvent('selectstart', true, false); |
135 getNodeInTreeOfTrees('shadow-host/target').dispatchEvent(event); | 135 getNodeInComposedTree('shadow-host/target').dispatchEvent(event); |
136 dumpDispatchedEvent('selectstart'); | 136 dumpDispatchedEvent('selectstart'); |
137 } | 137 } |
138 | 138 |
139 function test() | 139 function test() |
140 { | 140 { |
141 testEventsShouldNotBeStoppedAtShadowBoundary(); | 141 testEventsShouldNotBeStoppedAtShadowBoundary(); |
142 testEventsFiredOnDistributedNodesShouldNotBeStoppedAtShadowBoundary(); | 142 testEventsFiredOnDistributedNodesShouldNotBeStoppedAtShadowBoundary(); |
143 testEventsInMultipleShadowTrees(); | 143 testEventsInMultipleShadowTrees(); |
144 } | 144 } |
145 test(); | 145 test(); |
146 </script> | 146 </script> |
147 </body> | 147 </body> |
148 </html> | 148 </html> |
OLD | NEW |