summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/css/css-shadow-dom-inherits-styles.html
blob: b0b956ccef9c6a7e5674747c2d9a209dd6261d86 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script>
<script type="text/javascript" src="../../http/tests/inspector-protocol/dom-protocol-test.js"></script>
<script type="text/javascript">
function test()
{
    var documentNodeId;
    InspectorTest.eventHandler["DOM.setChildNodes"] = onChildNodes;
    InspectorTest.requestDocumentNodeId(onDocumentNodeId);

    var nodesMap = new Map();

    function onChildNodes(result)
    {
        for (var node of result.params.nodes)
            nodesMap.set(node.nodeId, node);
    }

    function onDocumentNodeId(nodeId)
    {
        documentNodeId = nodeId;
        InspectorTest.sendCommandOrDie("CSS.enable", {});
        InspectorTest.requestNodeId(nodeId, "#shadow-host", onHostReceived);
    }

    function onHostReceived(hostId)
    {
        var host = nodesMap.get(hostId);
        var root = host.shadowRoots[0];
        InspectorTest.requestNodeId(root.nodeId, "#inspected", onNodeReceived);
    }

    function onNodeReceived(nodeId)
    {
        InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, InspectorTest.completeTest.bind(InspectorTest));
    }
}
</script>
</head>
<style>
/** This style should be inherited by shadow DOM */
body {
    color: blue;
}
</style>
<body>
    <template>
        <div id="inspected">Inspect me.</div>
    </template>
    <div id="shadow-host">
    </div>
    <script type="text/javascript">
        var shadowRoot = document.querySelector("#shadow-host").createShadowRoot();
        var template = document.querySelector("template");
        var clone = document.importNode(template.content, true);
        shadowRoot.appendChild(clone);
        runTest();
    </script>
</body>
</html>