summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/shadow/layout-tests-can-access-shadow.html
blob: aed236bdd1fdc688e554abd053322597fe4f0c24 (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
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.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 throw.
    shouldThrow("internals.shadowRoot(shadow)");

    // Ordinary element should not have shadow
    var p = document.getElementById('peas');
    shouldBe('internals.shadowRoot(p)', 'null');

    // Can bless ordinary elements with shadows
    shadow = p.createShadowRoot(p);
    shouldBe('shadow.nodeName', '"#document-fragment"');
    shouldBe('shadow === internals.shadowRoot(p)', 'true');
}
</script>
</body>
</html>