blob: fcd53df3c16d047b12294a1eae842d57ed1cd959 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<!DOCTYPE html>
<html>
<head>
<script src="../../js/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>
</body>
</html>
|