test-001.html (2209B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Shadow DOM Test: A_05_02_01</title> 5 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> 6 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-201305214#retargeting-related-target"> 7 <meta name="assert" content="Retargeting relatedTarget:Event retargeting is a process of computing relative targets for each ancestor of the node at which the event is dispatched. A relative target is a DOM node that most accurately represents the target of a dispatched event at a given ancestor while maintaining the upper boundary encapsulation."> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="../../../../html/resources/common.js"></script> 11 <script src="../../../resources/shadow-dom-utils.js"></script> 12 </head> 13 <body> 14 <div id="log"></div> 15 <script> 16 var A_05_02_01_T01 = async_test('A_05_02_01_T1'); 17 18 A_05_02_01_T01.step(unit(function (ctx) { 19 20 var d = newRenderedHTMLDocument(ctx); 21 22 var host = d.createElement('div'); 23 host.setAttribute('style', 'height:100%; width:100%'); 24 host.setAttribute('id', 'host'); 25 d.body.appendChild(host); 26 27 //Shadow root to play with 28 var s = host.attachShadow({mode: 'open'}); 29 30 var div1 = d.createElement('div'); 31 div1.setAttribute('style', 'height:40px; width:100%'); 32 div1.setAttribute('id', 'div1'); 33 s.appendChild(div1); 34 35 var div2 = d.createElement('div'); 36 div2.setAttribute('style', 'height:40px; width:100%'); 37 div2.setAttribute('id', 'div2'); 38 s.appendChild(div2); 39 40 s.addEventListener('mouseover', A_05_02_01_T01.step_func(function(event) { 41 assert_equals(event.relatedTarget.getAttribute('id'), 'div1', 'Wrong relatedTarget'); 42 }), false); 43 44 d.body.addEventListener('mouseover', A_05_02_01_T01.step_func(function(event) { 45 assert_true(false, 'Event must be stopped at Shadow boundary'); 46 }), false); 47 48 49 var evt = document.createEvent("MouseEvents"); 50 evt.initMouseEvent("mouseover", true, false, window, 51 0, 10, 10, 10, 10, false, false, false, false, 0, div1); 52 53 div2.dispatchEvent(evt); 54 55 56 A_05_02_01_T01.done(); 57 })); 58 </script> 59 </body> 60 </html>