Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <style> | |
| 3 body { | |
| 4 margin: 0; | |
| 5 } | |
| 6 .non-fast { | |
| 7 height: 250px; | |
| 8 width: 250px; | |
| 9 display: block; | |
| 10 background-color: red; | |
| 11 overflow: scroll; | |
| 12 } | |
| 13 .non-fast > div { | |
| 14 height: 1000px; | |
| 15 width: 1000px; | |
| 16 display: block; | |
| 17 background: linear-gradient(to bottom, red, white); | |
| 18 } | |
| 19 </style> | |
| 20 | |
| 21 <div id="first" class="non-fast"> | |
| 22 This should be covered by the ONLY visible green overlay. | |
| 23 </div> | |
| 24 <div id="second" class="non-fast" style="margin-top:50px;"> | |
| 25 This should not be visible. | |
| 26 <div></div> | |
| 27 </div> | |
| 28 | |
| 29 <div id="console"></div> | |
| 30 | |
| 31 <script src="../resources/js-test.js"></script> | |
| 32 <script src="resources/non-fast-scrollable-region-testing.js"></script> | |
| 33 <script> | |
| 34 window.jsTestIsAsync = true; | |
| 35 description('This test ensures that changing visibility of a non-fast ' + | |
| 36 'scrollable area correctly updates list of non-fast scrollable ' + | |
| 37 'areas. (See http://crbug.com/434982)'); | |
| 38 | |
| 39 onload = function() { | |
| 40 awaitCompsitingUpdate(runTest); | |
| 41 }; | |
| 42 | |
| 43 function runTest() { | |
| 44 var first = document.getElementById('first'), | |
| 45 second = document.getElementById('second'); | |
| 46 | |
| 47 nonFastScrollableRects = internals.nonFastScrollableRects(document); | |
| 48 shouldBe('nonFastScrollableRects.length', '1'); | |
| 49 shouldBeEqualToString('rectToString(nonFastScrollableRects[0])', | |
| 50 '[0, 300, 250, 250]'); // second div | |
| 51 | |
| 52 // Hide container before making it non-fast scrollable to ensure any | |
| 53 // layout occurs while it is invisible. | |
| 54 first.style.visibility = 'hidden'; | |
| 55 makeNonFastScrollable(first); | |
| 56 | |
| 57 // Change visibility (hidden -> visible), which should not cause any layout, | |
| 58 // and verify that non-fast scrollable areas are correctly updated. | |
| 59 awaitCompsitingUpdate(function() { | |
| 60 first.style.visibility = 'visible'; | |
| 61 shouldBe('window.internals.needsLayoutCount()', '0'); | |
| 62 | |
| 63 awaitCompsitingUpdate(function() { | |
| 64 nonFastScrollableRects = internals.nonFastScrollableRects(document); | |
| 65 shouldBe('nonFastScrollableRects.length', '2'); | |
| 66 shouldBeEqualToString('rectToString(nonFastScrollableRects[0])', | |
| 67 '[0, 0, 250, 250]'); // first div | |
| 68 shouldBeEqualToString('rectToString(nonFastScrollableRects[1])', | |
| 69 '[0, 300, 250, 250]'); // second div | |
| 70 | |
| 71 // Change visibility (visible -> hidden) | |
| 72 second.style.visibility = 'hidden'; | |
| 73 shouldBe('window.internals.needsLayoutCount()', '0'); | |
| 74 | |
| 75 awaitCompsitingUpdate(function() { | |
| 76 // This has no functional impact just visual | |
| 77 runNonFastScrollableRegionTest(); | |
| 78 | |
| 79 nonFastScrollableRects = internals.nonFastScrollableRects(document); | |
| 80 shouldBe('nonFastScrollableRects.length', '1'); | |
| 81 shouldBeEqualToString('rectToString(nonFastScrollableRects[0])', | |
| 82 '[0, 0, 250, 250]'); // first div | |
| 83 | |
| 84 finishJSTest(); | |
| 85 }); | |
| 86 }); | |
| 87 }); | |
| 88 } | |
| 89 | |
| 90 // Makes the container non-fast scrollable area by appending a large element t o it. | |
| 91 function makeNonFastScrollable(container) { | |
| 92 var inner = document.createElement('div'); | |
| 93 container.appendChild(inner); | |
| 94 } | |
| 95 | |
| 96 // Waits for one RAF call to ensure compositing update is occurred and invokes task. | |
|
Rick Byers
2015/01/13 20:12:43
nit: s/is/has/
majidvp
2015/01/13 20:40:09
Done.
| |
| 97 function awaitCompsitingUpdate(task) { | |
| 98 window.requestAnimationFrame(task); | |
| 99 } | |
| 100 | |
| 101 function rectToString(rect) { | |
| 102 return '[' + [rect.left, rect.top, rect.width, rect.height].join(', ') + ']' ; | |
| 103 } | |
| 104 </script> | |
| OLD | NEW |