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 <keygen id="keys" /> | 7 <keygen id="keys" /> |
8 <p id="peas" /> | 8 <p id="peas" /> |
9 <pre id="console"> | 9 <pre id="console"> |
10 This tests that layout tests can access shadow DOM. | 10 This tests that layout tests can access shadow DOM. |
11 | 11 |
12 </pre> | 12 </pre> |
13 <script> | 13 <script> |
14 if (window.internals) { | 14 if (window.internals) { |
15 // Make assertions about a built-in shadow | 15 // Make assertions about a built-in shadow |
16 var keygen = document.getElementById('keys'); | 16 var keygen = document.getElementById('keys'); |
17 var shadow = internals.shadowRoot(keygen); | 17 var shadow = internals.shadowRoot(keygen); |
18 shouldBe('shadow.nodeName', '"#document-fragment"'); | 18 shouldBe('shadow.nodeName', '"#document-fragment"'); |
19 | 19 |
20 // Shadow roots aren't elements, so accessing their shadow should | 20 // Shadow roots aren't elements, so accessing their shadow should throw. |
21 // raise | 21 shouldThrow("internals.shadowRoot(shadow)"); |
22 var exceptionCode; | |
23 try { | |
24 internals.shadowRoot(shadow); | |
25 } catch (e) { | |
26 exceptionCode = e.code; | |
27 } | |
28 shouldBe('exceptionCode', 'DOMException.INVALID_ACCESS_ERR'); | |
29 | 22 |
30 // Ordinary element should not have shadow | 23 // Ordinary element should not have shadow |
31 var p = document.getElementById('peas'); | 24 var p = document.getElementById('peas'); |
32 shouldBe('internals.shadowRoot(p)', 'null'); | 25 shouldBe('internals.shadowRoot(p)', 'null'); |
33 | 26 |
34 // Can bless ordinary elements with shadows | 27 // Can bless ordinary elements with shadows |
35 shadow = p.createShadowRoot(p); | 28 shadow = p.createShadowRoot(p); |
36 shouldBe('shadow.nodeName', '"#document-fragment"'); | 29 shouldBe('shadow.nodeName', '"#document-fragment"'); |
37 shouldBe('shadow === internals.shadowRoot(p)', 'true'); | 30 shouldBe('shadow === internals.shadowRoot(p)', 'true'); |
38 } | 31 } |
39 </script> | 32 </script> |
40 </body> | 33 </body> |
41 </html> | 34 </html> |
OLD | NEW |