OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 Distributed under both the W3C Test Suite License [1] and the W3C |
| 4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
| 5 policies and contribution forms [3]. |
| 6 |
| 7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
| 8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
| 9 [3] http://www.w3.org/2004/10/27-testcases |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <title>Shadow DOM Test: Upper-boundary encapsulation: document's Selector APIs</
title> |
| 14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
| 15 <link rel="author" title="Yuta Kitamura" href="mailto:yutak@google.com"> |
| 16 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#upper-b
oundary-encapsulation"> |
| 17 <meta name="assert" content="Upper-boundary encapsulation: Nodes in a shadow tre
e must not be accessible through selector APIs of owner document."> |
| 18 <script src="../../../../../resources/testharness.js"></script> |
| 19 <script src="../../../../../resources/testharnessreport.js"></script> |
| 20 <script src="../../testcommon.js"></script> |
| 21 <link rel="stylesheet" href="../../../../../resources/testharness.css"> |
| 22 </head> |
| 23 <body> |
| 24 <div id="log"></div> |
| 25 <script> |
| 26 // Return a document containing the structure below: |
| 27 // |
| 28 // <body> - - - - - {shadow-root} |
| 29 // | | |
| 30 // | +-- <p class="test-class" id="test-id"> |
| 31 // | |
| 32 // +-- <p class="test-class" id="test-id"> |
| 33 function createTestDocument() { |
| 34 var doc = document.implementation.createHTMLDocument('Test'); |
| 35 var pHost = doc.createElement('p'); |
| 36 pHost.className = 'test-class'; |
| 37 pHost.id = 'test-id'; |
| 38 doc.body.appendChild(pHost); |
| 39 var shadowRoot = doc.body.createShadowRoot(); |
| 40 var pShadow = doc.createElement('p'); |
| 41 pShadow.className = 'test-class'; |
| 42 pShadow.id = 'test-id'; |
| 43 shadowRoot.appendChild(pShadow); |
| 44 return { |
| 45 doc: doc, |
| 46 pHost: pHost, |
| 47 pShadow: pShadow |
| 48 }; |
| 49 } |
| 50 |
| 51 test(function () { |
| 52 var documentObject = createTestDocument(); |
| 53 var doc = documentObject.doc; |
| 54 var pHost = documentObject.pHost; |
| 55 assert_equals(doc.querySelector('p'), pHost); |
| 56 assert_equals(doc.querySelector('.test-class'), pHost); |
| 57 assert_equals(doc.querySelector('#test-id'), pHost); |
| 58 }, |
| 59 'Elements in a shadow tree should not be accessible from ' + |
| 60 'owner document\'s querySelector() method.' |
| 61 ); |
| 62 |
| 63 function assert_singleton_node_list(nodeList, expectedNode) { |
| 64 assert_equals(nodeList.length, 1); |
| 65 assert_equals(nodeList[0], expectedNode); |
| 66 } |
| 67 |
| 68 test(function () { |
| 69 var documentObject = createTestDocument(); |
| 70 var doc = documentObject.doc; |
| 71 var pHost = documentObject.pHost; |
| 72 assert_singleton_node_list(doc.querySelectorAll('p'), pHost); |
| 73 assert_singleton_node_list(doc.querySelectorAll('.test-class'), pHost); |
| 74 assert_singleton_node_list(doc.querySelectorAll('#test-id'), pHost); |
| 75 }, |
| 76 'Elements in a shadow tree should not be accessible from ' + |
| 77 'owner document\'s querySelectorAll() method.' |
| 78 ); |
| 79 </script> |
| 80 </body> |
| 81 </html> |
OLD | NEW |