| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <keygen id="keys" /> |
| <p id="peas" /> |
| <pre id="console"> |
| This tests that layout tests can access shadow DOM. |
| |
| </pre> |
| <script> |
| if (window.internals) { |
| // Make assertions about a built-in shadow |
| var keygen = document.getElementById('keys'); |
| var shadow = internals.shadowRoot(keygen); |
| shouldBe('shadow.nodeName', '"#document-fragment"'); |
| |
| // Shadow roots aren't elements, so accessing their shadow should |
| // raise |
| var exceptionCode; |
| try { |
| internals.shadowRoot(shadow); |
| } catch (e) { |
| exceptionCode = e.code; |
| } |
| shouldBe('exceptionCode', 'DOMException.INVALID_ACCESS_ERR'); |
| |
| // Ordinary element should not have shadow |
| var p = document.getElementById('peas'); |
| shouldBe('internals.shadowRoot(p)', 'null'); |
| |
| // Can bless ordinary elements with shadows |
| shadow = internals.ensureShadowRoot(p); |
| shouldBe('shadow.nodeName', '"#document-fragment"'); |
| shouldBe('shadow === internals.shadowRoot(p)', 'true'); |
| } |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |