| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <div id="console"></div> | 7 <div id="console"></div> |
| 8 <!-- These elements should not be selected in ShadowRoot's querySelector. --> | 8 <!-- These elements should not be selected in ShadowRoot's querySelector. --> |
| 9 <div id="foo"></div> | 9 <div id="foo"></div> |
| 10 <div class="foo"></div> | 10 <div class="foo"></div> |
| 11 <foo></foo> | 11 <foo></foo> |
| 12 <script> | 12 <script> |
| 13 description("Tests for ShadowRoot JS APIs. Can only run within DRT"); | 13 description("Tests for ShadowRoot JS APIs. Can only run within DRT"); |
| 14 | 14 |
| 15 if (window.testRunner) | 15 if (window.testRunner) |
| 16 testRunner.dumpAsText(); | 16 testRunner.dumpAsText(); |
| 17 | 17 |
| 18 // WebKitShadowRoot is always available, while ShadowRoot is available when a ru
n-time flag is set | |
| 19 // (which is always enabled in testing). | 18 // (which is always enabled in testing). |
| 20 shouldBeDefined("window.ShadowRoot"); | 19 shouldBeDefined("window.ShadowRoot"); |
| 21 shouldBeDefined("window.WebKitShadowRoot"); | |
| 22 shouldThrow("new window.ShadowRoot(document.createElement('div'))"); | 20 shouldThrow("new window.ShadowRoot(document.createElement('div'))"); |
| 23 shouldThrow("new window.WebKitShadowRoot(document.createElement('div'))"); | |
| 24 | 21 |
| 25 var shadowHost = document.createElement('div'); | 22 var shadowHost = document.createElement('div'); |
| 26 document.body.appendChild(shadowHost); | 23 document.body.appendChild(shadowHost); |
| 27 var shadowRoot = shadowHost.createShadowRoot(); | 24 var shadowRoot = shadowHost.createShadowRoot(); |
| 28 | 25 |
| 29 shouldBeTrue("shadowRoot instanceof window.ShadowRoot"); | 26 shouldBeTrue("shadowRoot instanceof window.ShadowRoot"); |
| 30 shouldBeTrue("shadowRoot instanceof window.WebKitShadowRoot"); | |
| 31 | 27 |
| 32 var div1 = document.createElement("div"); | 28 var div1 = document.createElement("div"); |
| 33 div1.setAttribute("id", "div1"); | 29 div1.setAttribute("id", "div1"); |
| 34 shadowRoot.appendChild(div1); | 30 shadowRoot.appendChild(div1); |
| 35 | 31 |
| 36 var div2 = document.createElement("div"); | 32 var div2 = document.createElement("div"); |
| 37 div2.setAttribute("id", "div2"); | 33 div2.setAttribute("id", "div2"); |
| 38 div2.classList.add("class2"); | 34 div2.classList.add("class2"); |
| 39 shadowRoot.appendChild(div2); | 35 shadowRoot.appendChild(div2); |
| 40 | 36 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 59 shouldBe("shadowRoot.querySelector('.class2')", "div2"); | 55 shouldBe("shadowRoot.querySelector('.class2')", "div2"); |
| 60 shouldBeNull("shadowRoot.querySelector('.foo')"); | 56 shouldBeNull("shadowRoot.querySelector('.foo')"); |
| 61 shouldBe("shadowRoot.querySelectorAll('div')", "[div1, div2]"); | 57 shouldBe("shadowRoot.querySelectorAll('div')", "[div1, div2]"); |
| 62 shouldBe("shadowRoot.querySelectorAll('foo')", "[]"); | 58 shouldBe("shadowRoot.querySelectorAll('foo')", "[]"); |
| 63 | 59 |
| 64 var youngerShadowRoot = shadowHost.createShadowRoot(); | 60 var youngerShadowRoot = shadowHost.createShadowRoot(); |
| 65 shouldNotBe("youngerShadowRoot", "shadowRoot"); | 61 shouldNotBe("youngerShadowRoot", "shadowRoot"); |
| 66 </script> | 62 </script> |
| 67 </body> | 63 </body> |
| 68 </html> | 64 </html> |
| OLD | NEW |