summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-scoping/css-scoping-shadow-host-namespace.html
blob: 46dffc8de38a52a6448e2e7692e6af0d7be1177d (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
    <title>CSS Scoping Module Level 1 - :host, :host-context, and default @namespace</title>
    <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
    <link rel="help" href="https://www.w3.org/TR/css-scoping-1/#host-selector">
    <link rel="help" href="https://www.w3.org/TR/css3-selectors/#typenmsp">
    <link rel="help" href="https://www.w3.org/TR/css3-selectors/#univnmsp">
    <link rel="match" href="reference/green-box.html"/>
</head>
<body>
    <style>
        .host {
            display: block;
            width: 100px;
            height: 10px;
            background: red;
        }
        #host-3, #host-5, #host-10 {
            background: green;
        }
    </style>
    <p>Test passes if you see a single 100px by 100px green box below.</p>
    <div id="host-1" class="host">FAIL</div>
    <div id="host-2" class="host">FAIL</div>
    <div id="host-3" class="host">FAIL</div>
    <div id="host-4" class="host">FAIL</div>
    <div id="host-5" class="host">FAIL</div>
    <div id="host-6" class="host">FAIL</div>
    <div id="host-7" class="host">FAIL</div>
    <div id="host-8" class="host">FAIL</div>
    <div id="host-9" class="host">FAIL</div>
    <div id="host-10" class="host">FAIL</div>
    <script>
        try {
            var shadowHost = document.querySelector('#host-1');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host { background: green !important; } </style>';

            shadowHost = document.querySelector('#host-2');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host { background: green !important; } </style>';

            shadowHost = document.querySelector('#host-3');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host(*) { background: red !important; } </style>';

            shadowHost = document.querySelector('#host-4');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host(*|*) { background: green !important; } </style>';

            shadowHost = document.querySelector('#host-5');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host-context(*) { background: red !important; } </style>';

            shadowHost = document.querySelector('#host-6');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host-context(*|*) { background: green !important; } </style>';

            shadowHost = document.querySelector('#host-7');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host(*) { background: green !important; } </style>';

            shadowHost = document.querySelector('#host-8');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host-context(*) { background: green !important; } </style>';

            shadowHost = document.querySelector('#host-9');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host(div) { background: green !important; } </style>';

            shadowHost = document.querySelector('#host-10');
            shadowRoot = shadowHost.attachShadow({mode: 'open'});
            shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host-context(html) { background: red !important; } </style>';

        } catch (exception) {
            document.body.appendChild(document.createTextNode(exception));
        }

    </script>
</body>
</html>