| 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: shadow root's Selector API
    s</title> | 
 |  14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> | 
 |  15 <link rel="author" title="Mikhail Fursov" href="mailto:mfursov@unipro.ru"> | 
 |  16 <link rel="author" title="Yuta Kitamura" href="mailto:yutak@google.com"> | 
 |  17 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#upper-b
    oundary-encapsulation"> | 
 |  18 <meta name="assert" content="Upper-boundary encapsulation: Nodes in a shadow tre
    e must be accessible through selector APIs of the shadow root."> | 
 |  19 <script src="../../../../../resources/testharness.js"></script> | 
 |  20 <script src="../../../../../resources/testharnessreport.js"></script> | 
 |  21 <script src="../../testcommon.js"></script> | 
 |  22 <link rel="stylesheet" href="../../../../../resources/testharness.css"> | 
 |  23 </head> | 
 |  24 <body> | 
 |  25 <div id="log"></div> | 
 |  26 <script> | 
 |  27 // Return a document containing the structure below: | 
 |  28 // | 
 |  29 // <body> - - - - - {shadow-root} | 
 |  30 //   |                    | | 
 |  31 //   |                    +-- <p class="test-class" id="test-id"> | 
 |  32 //   | | 
 |  33 //   +-- <p class="test-class" id="test-id"> | 
 |  34 function createTestDocument() { | 
 |  35     var doc = document.implementation.createHTMLDocument('Test'); | 
 |  36     var pHost = doc.createElement('p'); | 
 |  37     pHost.className = 'test-class'; | 
 |  38     pHost.id = 'test-id'; | 
 |  39     doc.body.appendChild(pHost); | 
 |  40     var shadowRoot = doc.body.createShadowRoot(); | 
 |  41     var pShadow = doc.createElement('p'); | 
 |  42     pShadow.className = 'test-class'; | 
 |  43     pShadow.id = 'test-id'; | 
 |  44     shadowRoot.appendChild(pShadow); | 
 |  45     return { | 
 |  46         doc: doc, | 
 |  47         shadowRoot: shadowRoot, | 
 |  48         pHost: pHost, | 
 |  49         pShadow: pShadow | 
 |  50     }; | 
 |  51 } | 
 |  52  | 
 |  53 test(function () { | 
 |  54     var documentObject = createTestDocument(); | 
 |  55     var shadowRoot = documentObject.shadowRoot; | 
 |  56     var pShadow = documentObject.pShadow; | 
 |  57     assert_equals(shadowRoot.querySelector('p'), pShadow); | 
 |  58     assert_equals(shadowRoot.querySelector('.test-class'), pShadow); | 
 |  59     assert_equals(shadowRoot.querySelector('#test-id'), pShadow); | 
 |  60 }, | 
 |  61     'Elements in a shadow tree should be accessible from ' + | 
 |  62     'shadow root\'s querySelector() method.' | 
 |  63 ); | 
 |  64  | 
 |  65 function assert_singleton_node_list(nodeList, expectedNode) { | 
 |  66     assert_equals(nodeList.length, 1); | 
 |  67     assert_equals(nodeList[0], expectedNode); | 
 |  68 } | 
 |  69  | 
 |  70 test(function () { | 
 |  71     var documentObject = createTestDocument(); | 
 |  72     var shadowRoot = documentObject.shadowRoot; | 
 |  73     var pShadow = documentObject.pShadow; | 
 |  74     assert_singleton_node_list(shadowRoot.querySelectorAll('p'), pShadow); | 
 |  75     assert_singleton_node_list(shadowRoot.querySelectorAll('.test-class'), | 
 |  76                                pShadow); | 
 |  77     assert_singleton_node_list(shadowRoot.querySelectorAll('#test-id'), | 
 |  78                                pShadow); | 
 |  79 }, | 
 |  80     'Elements in a shadow tree should be accessible from ' + | 
 |  81     'shadow root\'s querySelectorAll() method.' | 
 |  82 ); | 
 |  83 </script> | 
 |  84 </body> | 
 |  85 </html> | 
| OLD | NEW |