OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <style> |
| 5 #container { |
| 6 width: 200px; |
| 7 height: 200px; |
| 8 overflow: scroll; |
| 9 margin: 20px; |
| 10 border: 1px solid black; |
| 11 } |
| 12 |
| 13 #abs-pos-ancestor { |
| 14 width: 500px; |
| 15 height: 500px; |
| 16 position: absolute; |
| 17 z-index: 0; |
| 18 } |
| 19 |
| 20 #positioned-ancestor { |
| 21 width: 150px; |
| 22 height: 300px; |
| 23 position: relative; |
| 24 } |
| 25 |
| 26 #descendant { |
| 27 left: 10px; |
| 28 top: 10px; |
| 29 width: 50px; |
| 30 height: 50px; |
| 31 background-color: blue; |
| 32 position: absolute; |
| 33 z-index: -20; |
| 34 } |
| 35 </style> |
| 36 <script> |
| 37 var debugMode = false; |
| 38 |
| 39 if (window.testRunner) |
| 40 testRunner.dumpAsText(); |
| 41 |
| 42 if (window.internals) |
| 43 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnable
d(true); |
| 44 |
| 45 function write(str) |
| 46 { |
| 47 var pre = document.getElementById('console'); |
| 48 var text = document.createTextNode(str + '\n'); |
| 49 pre.appendChild(text); |
| 50 } |
| 51 |
| 52 var iteration = 0; |
| 53 function printResult(expectedResult) |
| 54 { |
| 55 // Force a style recalc. |
| 56 document.body.offsetTop; |
| 57 |
| 58 if (window.internals) { |
| 59 var layerTree = window.internals.layerTreeAsText(document); |
| 60 |
| 61 var passed = !layerTree == !expectedResult; |
| 62 if (passed) |
| 63 write('Iteration ' + iteration.toString() + ': Passed') |
| 64 else |
| 65 write('Iteration ' + iteration.toString() + ': FAILED') |
| 66 |
| 67 if (layerTree) { |
| 68 write('Iteration ' + iteration.toString() + ', layer tree'); |
| 69 if (debugMode || !passed) |
| 70 write(layerTree); |
| 71 } else |
| 72 write('Iteration ' + iteration.toString() + ', no layer tree'); |
| 73 } |
| 74 iteration++; |
| 75 } |
| 76 |
| 77 function doTest() |
| 78 { |
| 79 var container = document.getElementById('container'); |
| 80 var positionedAncestor = document.getElementById('positioned-ancestor'); |
| 81 var descendant = document.getElementById('descendant'); |
| 82 |
| 83 // Initial configuration should opt in. |
| 84 printResult(true); |
| 85 |
| 86 // If positioned ancestor ceases to be positioned, the containing |
| 87 // will become the abs-pos-ancestor. We should opt out. |
| 88 positionedAncestor.style.position = 'static'; |
| 89 printResult(false); |
| 90 |
| 91 // If we get rid of the out-of-flow positioned descendant at this point, |
| 92 // it should be ok to opt back in. |
| 93 descendant.style.display = 'none'; |
| 94 printResult(true); |
| 95 |
| 96 // This should return us to our previous state. |
| 97 descendant.style.display = ''; |
| 98 printResult(false); |
| 99 |
| 100 // If the descendant ceases to be out-of-flow-positioned, then we should |
| 101 // opt in. |
| 102 descendant.style.position = 'static'; |
| 103 printResult(true); |
| 104 |
| 105 // This should return us to our previous state. |
| 106 descendant.style.position = ''; |
| 107 printResult(false); |
| 108 |
| 109 // If the positionedAncestor again becomes positioned, it will become the |
| 110 // containing block for the descendant and we should opt in. |
| 111 positionedAncestor.style.position = 'relative'; |
| 112 printResult(true); |
| 113 } // function doTest |
| 114 |
| 115 window.addEventListener('load', doTest, false); |
| 116 </script> |
| 117 </head> |
| 118 |
| 119 <body> |
| 120 <div id="abs-pos-ancestor"> |
| 121 <div id="container"> |
| 122 <div id="positioned-ancestor"> |
| 123 <div id="descendant"></div> |
| 124 </div> |
| 125 </div> |
| 126 </div> |
| 127 <pre id="console"></pre> |
| 128 </body> |
| 129 </html> |
| 130 |
OLD | NEW |