OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="resources/shadow-dom.js"></script> | 4 <script src="resources/shadow-dom.js"></script> |
5 <script src="../../../resources/js-test.js"></script> | 5 <script src="../../../resources/js-test.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <div id='sandbox'> | 8 <div id='sandbox'> |
9 <div id='target5' class='bar'>Should have blue background.</div> | 9 <div id='target5' class='bar'>Should have blue background.</div> |
10 </div> | 10 </div> |
11 <pre id='console'></pre> | 11 <pre id='console'></pre> |
12 </body> | 12 </body> |
13 <script> | 13 <script> |
14 | |
15 function backgroundColorOf(node) | |
16 { | |
17 return document.defaultView.getComputedStyle(node, null).getPropertyValue('b
ackground-color'); | |
18 } | |
19 | |
20 function backgroundColorShouldBe(selector, color) | |
21 { | |
22 var text = 'backgroundColorOf(getNodeInTreeOfTrees("' + selector + '"))'; | |
23 shouldBeEqualToString(text, color); | |
24 } | |
25 | |
26 var sandbox = document.getElementById('sandbox'); | 14 var sandbox = document.getElementById('sandbox'); |
27 sandbox.appendChild( | 15 sandbox.appendChild( |
28 createDOM('div', {'id': 'host'}, | 16 createDOM('div', {'id': 'host'}, |
29 createShadowRoot( | 17 createShadowRoot( |
30 createDOM('div', {'id': 'target1', 'class': 'foo'}, | 18 createDOM('div', {'id': 'target1', 'class': 'foo'}, |
31 document.createTextNode('Should have green background')), | 19 document.createTextNode('Should have green background')), |
32 createDOM('div', {'id': 'target2'}, | 20 createDOM('div', {'id': 'target2'}, |
33 document.createTextNode('Should have green background')), | 21 document.createTextNode('Should have green background')), |
34 createDOM('div', {'id': 'target3', 'class': 'bar'}, | 22 createDOM('div', {'id': 'target3', 'class': 'bar'}, |
35 document.createTextNode('Should have blue background')), | 23 document.createTextNode('Should have blue background')), |
36 createDOM('div', {'id': 'target4'}, | 24 createDOM('div', {'id': 'target4'}, |
37 document.createTextNode('Should have blue background'))))); | 25 document.createTextNode('Should have blue background'))))); |
38 document.body.offsetLeft; | 26 document.body.offsetLeft; |
39 | 27 |
40 var style = document.createElement('style'); | 28 var style = document.createElement('style'); |
41 style.innerHTML = 'div::shadow .foo { background: green; }' | 29 style.innerHTML = 'div::shadow .foo { background: green; }' |
42 + 'div::shadow #target2 { background: green; }' | 30 + 'div::shadow #target2 { background: green; }' |
43 + 'div /deep/ .bar { background: blue; }' | 31 + 'div /deep/ .bar { background: blue; }' |
44 + 'div /deep/ #target4 { background: blue; }'; | 32 + 'div /deep/ #target4 { background: blue; }'; |
45 document.body.appendChild(style); | 33 document.body.appendChild(style); |
46 | 34 |
47 backgroundColorShouldBe('host/target1', 'rgb(0, 128, 0)'); | 35 backgroundColorShouldBe('host/target1', 'rgb(0, 128, 0)'); |
48 backgroundColorShouldBe('host/target2', 'rgb(0, 128, 0)'); | 36 backgroundColorShouldBe('host/target2', 'rgb(0, 128, 0)'); |
49 backgroundColorShouldBe('host/target3', 'rgb(0, 0, 255)'); | 37 backgroundColorShouldBe('host/target3', 'rgb(0, 0, 255)'); |
50 backgroundColorShouldBe('host/target4', 'rgb(0, 0, 255)'); | 38 backgroundColorShouldBe('host/target4', 'rgb(0, 0, 255)'); |
51 backgroundColorShouldBe('target5', 'rgb(0, 0, 255)'); | 39 backgroundColorShouldBe('target5', 'rgb(0, 0, 255)'); |
52 </script> | 40 </script> |
53 </html> | 41 </html> |
OLD | NEW |