2 <script src="resources/shadow-dom.js"></script>
3 <script src="../../../resources/js-test.js"></script>
5 <div id='sandbox'></div>
10 return document.defaultView.getComputedStyle(node, null).getPropertyValue('color');
13 function colorShouldBe(selector, color)
15 var text = 'colorOf(getNodeInTreeOfTrees("' + selector + '"))';
16 shouldBeEqualToString(text, color);
19 function colorShouldNotBe(selector, color)
21 var text = 'colorOf(getNodeInTreeOfTrees("' + selector + '"))';
22 var unevaledString = '"' + color.replace(/\\/g, "\\\\").replace(/"/g, "\"") + '"';
23 shouldNotBe(text, unevaledString);
28 document.getElementById('sandbox').innerHTML = '';
31 description('Test for ::shadow pseudo element, http://crbug.com/367266.');
35 createDOM('style', {'id': 'style-with-shadow'},
36 document.createTextNode('div::shadow { color: red; }')),
37 createDOM('div', {'id': 'host'},
39 createDOM('div', {'id': 'target'},
40 document.createTextNode('not red color.'))))));
42 colorShouldNotBe('host/target', 'rgb(255, 0, 0)');
44 var styleWithShadow = document.getElementById('style-with-shadow');
45 styleWithShadow.innerHTML = ':not(div::shadow) { color: red; }';
47 colorShouldNotBe('host/target', 'rgb(255, 0, 0)');
49 styleWithShadow.innerHTML = ':-webkit-any(div::shadow, div::shadow div) { color: red; }';
51 colorShouldNotBe('host/target', 'rgb(255, 0, 0)');
57 createDOM('style', {},
58 document.createTextNode('div::shadow + div { color: red; }')),
59 createDOM('div', {'id': 'host'},
61 createDOM('div', {'id': 'first-direct-child'},
62 document.createTextNode('not red color.')),
63 createDOM('div', {'id': 'second-direct-child'},
64 document.createTextNode('not red color.')))),
65 createDOM('div', {'id': 'host-sibling'},
66 document.createTextNode('not red color.'))));
68 colorShouldNotBe('host/first-direct-child', 'rgb(255, 0, 0)');
69 colorShouldNotBe('host/second-direct-child', 'rgb(255, 0, 0)');
70 colorShouldNotBe('host-sibling', 'rgb(255, 0, 0)');
76 createDOM('style', {},
77 document.createTextNode('div::shadow ~ div { color: red; }')),
78 createDOM('div', {'id': 'host'},
80 createDOM('div', {'id': 'first-direct-child'},
81 document.createTextNode('not red color.')),
82 createDOM('div', {'id': 'second-direct-child'},
83 document.createTextNode('not red color.')))),
84 createDOM('div', {'id': 'host-sibling'},
85 document.createTextNode('not red color.'))));
87 colorShouldNotBe('host/first-direct-child', 'rgb(255, 0, 0)');
88 colorShouldNotBe('host/second-direct-child', 'rgb(255, 0, 0)');
89 colorShouldNotBe('host-sibling', 'rgb(255, 0, 0)');
95 createDOM('style', {},
96 document.createTextNode('div::shadow > div { color: green; }')),
97 createDOM('div', {'id': 'host'},
99 createDOM('div', {'id': 'direct-child'},
100 document.createTextNode('green color.')),
102 createDOM('div', {'id': 'not-direct-child'},
103 document.createTextNode('not green color.'))))),
104 createDOM('div', {'id': 'host-child'},
105 document.createTextNode('not green color.'))));
107 colorShouldBe('host/direct-child', 'rgb(0, 128, 0)');
108 colorShouldNotBe('host/not-direct-child', 'rgb(0, 128, 0)');
109 colorShouldNotBe('host-child', 'rgb(0, 128, 0)');