OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html><body> | 2 <html><body> |
3 <script src="../../../resources/js-test.js"></script> | 3 <script src="../../../resources/js-test.js"></script> |
4 | 4 |
5 <p>When selecting from non-anchor Node to anchor node in ShadowDOM, client shoul
d not cause page jump.</p> | 5 <p>When selecting from non-anchor Node to anchor node in ShadowDOM, client shoul
d not cause page jump.</p> |
6 | 6 |
7 <div id="host"></div> | 7 <div id="host"></div> |
8 <pre id="console"></pre> | 8 <pre id="console"></pre> |
9 | 9 |
10 <script> | 10 <script> |
11 function mouseMoveTo(element) | 11 function mouseMoveTo(element) |
12 { | 12 { |
13 var x = element.offsetLeft + element.offsetWidth / 2; | 13 var x = element.offsetLeft + element.offsetWidth / 2; |
14 var y = element.offsetTop + element.offsetHeight / 2; | 14 var y = element.offsetTop + element.offsetHeight / 2; |
15 eventSender.mouseMoveTo(x, y); | 15 eventSender.mouseMoveTo(x, y); |
16 } | 16 } |
17 | 17 |
18 var shadowRoot = host.createShadowRoot(); | 18 var shadowRoot = host.createShadowRoot(); |
19 shadowRoot.innerHTML = '<span>select form here</span><a href="javascript:alert(\
'FAIL\');">select to here</a>'; | 19 shadowRoot.innerHTML = '<span>select form here</span><a href="javascript:alert(\
'FAIL\');">select to here</a>'; |
20 | 20 |
21 var lastClickTarget = null; | 21 var lastClickTarget = null; |
22 host.addEventListener('click', function(e) { | 22 host.addEventListener('click', function(e) { |
23 lastClickTarget = e.target; | 23 lastClickTarget = e.target; |
24 }); | 24 }); |
25 shadowRoot.lastChild.addEventListener('click', function(e) { | 25 shadowRoot.lastChild.addEventListener('click', function(e) { |
26 testFailed('Click event on an anchor element should not be fired.'); | 26 testFailed('Click event on an anchor element should not be fired.'); |
27 }, false); | 27 }, false); |
28 | 28 |
29 debug('Selecting from a node to another node in ShadowDOM. This should fire clic
k event on the host.'); | 29 debug('Selecting from a node to another node in ShadowDOM. This should not start
page navigation.'); |
30 mouseMoveTo(shadowRoot.firstChild); | 30 mouseMoveTo(shadowRoot.firstChild); |
31 eventSender.mouseDown(); | 31 eventSender.mouseDown(); |
32 mouseMoveTo(shadowRoot.firstChild.nextSibling); | 32 mouseMoveTo(shadowRoot.firstChild.nextSibling); |
33 eventSender.mouseUp(); | 33 eventSender.mouseUp(); |
34 shouldBe('lastClickTarget', 'host'); | 34 shouldBeNull('lastClickTarget'); |
35 debug(''); | 35 debug(''); |
36 | 36 |
37 lastClickTarget = null; | 37 lastClickTarget = null; |
38 debug('Clicking a node in ShadowDOM.'); | 38 debug('Clicking a node in ShadowDOM.'); |
39 mouseMoveTo(shadowRoot.firstChild); | 39 mouseMoveTo(shadowRoot.firstChild); |
40 eventSender.mouseDown(); | 40 eventSender.mouseDown(); |
41 eventSender.mouseUp(); | 41 eventSender.mouseUp(); |
42 shouldBe('lastClickTarget', 'host'); | 42 shouldBe('lastClickTarget', 'host'); |
43 debug(''); | 43 debug(''); |
44 | 44 |
45 </script> | 45 </script> |
46 | 46 |
47 </body></body> | 47 </body></body> |
OLD | NEW |