3 Distributed under both the W3C Test Suite License [1] and the W3C
4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
5 policies and contribution forms [3].
7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
9 [3] http://www.w3.org/2004/10/27-testcases
13 <title>Shadow DOM Test: The matching specificity of CSS rules for @host @-rule</title>
14 <link rel="author" title="Moto Ishizawa" href="mailto:summerwind.jp@gmail.com">
15 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#host-at-rule">
16 <meta name="assert" content="@host @-rule: Test the matching specificity of CSS rules for @host">
17 <script src="../../../../../resources/testharness.js"></script>
18 <script src="../../../../../resources/testharnessreport.js"></script>
19 <script src="../../testcommon.js"></script>
20 <link rel="stylesheet" href="../../../../../resources/testharness.css">
22 #test-id { display: block; }
23 .test-class { display: block; }
24 li { display: block; }
30 test(unit(function (ctx) {
31 var d = newRenderedHTMLDocument(ctx);
36 '<li id="test-id">2</li>' +
37 '<li class="test-class">3</li>' +
38 '<li id="test-id" class="test-class">4</li>' +
39 '<li style="display: block;">5</li>' +
42 var host = d.querySelector('#host');
43 var s = createSR(host);
45 var div = d.createElement('div');
46 div.innerHTML = '<div id="shDiv"><span>Div in the Shadow tree</span></div>'
47 + '<ul><content></content></ul>';
50 var style = d.createElement('style');
51 style.textContent = '@host {'
52 + 'li { display: none; }'
56 var li_list = d.querySelectorAll('#host li');
57 assert_equals(li_list[0].offsetHeight, 0, 'Point 1: @host rules applies');
58 assert_equals(li_list[1].offsetHeight, 0, 'Point 2: @host rules applies');
59 assert_equals(li_list[2].offsetHeight, 0, 'Point 3: @host rules applies');
60 assert_equals(li_list[3].offsetHeight, 0, 'Point 4: @host rules applies');
61 assert_not_equals(li_list[4].offsetHeight, 0, 'Point 5: style attribute value applies');
62 }), 'Only the last "li" element of shadow trees is displayed');