test-001.html (1563B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Shadow DOM Test: A_10_01_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-20130514/#shadow-root-methods"> 7 <meta name="assert" content="ShadowRoot Object: HTMLElement getElementById(DOMString elementId) method"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="../../../../../html/resources/common.js"></script> 11 </head> 12 <body> 13 <div id="log"></div> 14 <script> 15 test(function () { 16 17 var d = newHTMLDocument(); 18 19 var el = d.createElement('div'); 20 d.body.appendChild(el); 21 22 var s = el.attachShadow({mode: 'open'}); 23 24 var child = d.createElement('span'); 25 child.setAttribute('id', 'span_id'); 26 s.appendChild(child); 27 28 assert_true(s.getElementById('span_id') != null, 'Point 1: ShadowRoot getElementById() ' + 29 'method should return child element'); 30 assert_equals(s.getElementById('span_id').getAttribute('id'), 'span_id', 'Point 2: ' + 31 'ShadowRoot getElementById() method should return child element'); 32 33 }, 'A_10_01_02_01_T01'); 34 35 36 37 test(function () { 38 39 var d = newHTMLDocument(); 40 41 var el = d.createElement('div'); 42 d.body.appendChild(el); 43 44 var s = el.attachShadow({mode: 'open'}); 45 46 assert_true(s.getElementById('span_id') == null, ' ShadowRoot getElementById() ' + 47 'method should return null if matching element not found'); 48 49 }, 'A_10_01_02_01_T02'); 50 </script> 51 </body> 52 </html>