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