shadow-root-001.html (2365B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Shadow DOM Test: Shadow root's parentNode() and parentElement()</title> 5 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> 6 <link rel="author" title="Mikhail Fursov" href="mailto:mfursov@unipro.ru"> 7 <link rel="author" title="Yuta Kitamura" href="mailto:yutak@google.com"> 8 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#upper-boundary-encapsulation"> 9 <meta name="assert" content="Upper-boundary encapsulation: The parentNode and parentElement attributes of the shadow root object must always return null."> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script src="../../../../html/resources/common.js"></script> 13 </head> 14 <body> 15 <div id="log"></div> 16 <script> 17 test(function () { 18 var doc = document.implementation.createHTMLDocument('Test'); 19 var shadowRoot = doc.body.attachShadow({mode: 'open'}); 20 assert_equals(shadowRoot.parentNode, null); 21 }, 'The parentNode attribute of a shadow root must always return null.'); 22 23 test(function () { 24 var doc = document.implementation.createHTMLDocument('Test'); 25 var shadowRoot = doc.body.attachShadow({mode: 'open'}); 26 assert_equals(shadowRoot.parentElement, null); 27 }, 'The parentElement attribute of a shadow root must always return null.'); 28 29 test(function () { 30 var doc = document.implementation.createHTMLDocument('Test'); 31 var outerShadowRoot = doc.body.attachShadow({mode: 'open'}); 32 var div = doc.createElement('div'); 33 outerShadowRoot.appendChild(div); 34 var innerShadowRoot = div.attachShadow({mode: 'open'}); 35 assert_equals(innerShadowRoot.parentNode, null); 36 }, 37 'The parentNode attribute of a shadow root must always return null, ' + 38 'even if the shadow root is nested inside another shadow root.' 39 ); 40 41 test(function () { 42 var doc = document.implementation.createHTMLDocument('Test'); 43 var outerShadowRoot = doc.body.attachShadow({mode: 'open'}); 44 var div = doc.createElement('div'); 45 outerShadowRoot.appendChild(div); 46 var innerShadowRoot = div.attachShadow({mode: 'open'}); 47 assert_equals(innerShadowRoot.parentElement, null); 48 }, 49 'The parentElement attribute of a shadow root must always return null, ' + 50 'even if the shadow root is nested inside another shadow root.' 51 ); 52 </script> 53 </body> 54 </html>