summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/shadow-dom-scope.html
blob: 70e5a369caa994ac249920f062c6ff0a3adc0dc8 (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
<html>
<head>
<title>Selectors and Shadow Scopes</title>
<style>
    input[type=range] {
        -webkit-appearance: none;
    }
</style>
<script>

if (window.testRunner)
    testRunner.dumpAsText();

var head;
var input;
var logDiv;
var SELECTOR_TEST_PROPERTIES = ' { height: 1px; -webkit-appearance: none; }';

// convenience constants
var MATCH = true;
var NO_MATCH = false;

function log(msg, success)
{
    logDiv.appendChild(document.createElement('div')).innerHTML = msg + ': ' + (success ? 'PASS' : 'FAIL');
}

function runSelectorTest(matchExpected, selector)
{
    var style = document.createElement('style');
    style.textContent = selector + SELECTOR_TEST_PROPERTIES;
    head.appendChild(style);
    var matched = input.offsetHeight == 1;
    log('<code>' + selector + '</code> <strong>should' + (matchExpected ? '' : ' not') + '</strong> match', matchExpected ? matched : !matched);
    head.removeChild(style);
}

function runTest()
{
    head = document.getElementsByTagName('head')[0];
    input = document.getElementsByTagName('input')[0];
    logDiv = document.getElementById('log');
    runSelectorTest(NO_MATCH, 'div');
    runSelectorTest(NO_MATCH, '*');
    runSelectorTest(NO_MATCH, 'body *');
    document.body.removeChild(input);
}

</script>
</head>
<body onload="runTest()">
    <p>Tests whether and how selectors cross shadow DOM scopes.</p>
    <input id="foo" class="bar" style="height:auto" type="range">
    <div id="log"></div>
</body>
</html>