OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/run-after-display.js"></script> | |
3 <script> | 2 <script> |
4 onload = function() { | 3 onload = function() { |
5 var host = document.getElementById('host'); | 4 var host = document.getElementById('host'); |
6 var sr = host.createShadowRoot(); | 5 var sr = host.createShadowRoot(); |
7 // To make documentScopeDirty clean, add fake style element to document. | 6 // To make documentScopeDirty clean, add fake style element to document. |
8 document.head.appendChild(document.createElement('style')); | 7 document.head.appendChild(document.createElement('style')); |
9 // Should invoke style recalc here. | 8 // Should invoke style recalc here. |
10 document.body.offsetLeft; | 9 document.body.offsetLeft; |
11 | 10 |
12 // Need a parent element of a shadow host. | 11 // Need a parent element of a shadow host. |
13 // Shadow hosts' styles are recalc-ed by updating styles in shadow trees, bu
t | 12 // Shadow hosts' styles are recalc-ed by updating styles in shadow trees, bu
t |
14 // Their parents are not recalc-ed. | 13 // Their parents are not recalc-ed. |
15 var parentOfHostInShadow = document.createElement('div'); | 14 var parentOfHostInShadow = document.createElement('div'); |
16 var hostInShadow = document.createElement('div'); | 15 var hostInShadow = document.createElement('div'); |
17 parentOfHostInShadow.appendChild(hostInShadow); | 16 parentOfHostInShadow.appendChild(hostInShadow); |
18 | 17 |
19 // Create shadow tree with style which has @import. | 18 // Create shadow tree with style which has @import. |
20 var sr2 = hostInShadow.createShadowRoot(); | 19 var sr2 = hostInShadow.createShadowRoot(); |
21 sr2.innerHTML = '<style>@import url("../../css/resources/green.css");</style
><div>PASS</div></style>'; | 20 sr2.innerHTML = '<style>@import url("../../css/resources/green.css");</style
><div>PASS</div></style>'; |
22 sr.appendChild(parentOfHostInShadow); | 21 sr.appendChild(parentOfHostInShadow); |
23 | 22 |
24 // Force style recalc before sheetLoaded here. | 23 // Force style recalc before sheetLoaded here. |
25 // document.body.offset is slow. It causes style recalc after sheetLoaded. | 24 // document.body.offset is slow. It causes style recalc after sheetLoaded. |
26 // Instead, use internals.updateStyleAndReturnAffectedElementCount | 25 // Instead, use internals.updateStyleAndReturnAffectedElementCount |
27 // (to emulate @import's network delay). | 26 // (to emulate @import's network delay). |
28 internals.updateStyleAndReturnAffectedElementCount(); | 27 internals.updateStyleAndReturnAffectedElementCount(); |
29 | |
30 if (window.testRunner) | |
31 testRunner.waitUntilDone(); | |
32 runAfterDisplay(function() { | |
33 if (window.testRunner) | |
34 testRunner.notifyDone(); | |
35 }); | |
36 } | 28 } |
37 </script> | 29 </script> |
38 <div id="host"></div> | 30 <div id="host"></div> |
OLD | NEW |