Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <style> | |
| 3 body { | |
| 4 height: 2000px; | |
| 5 width: 2000px; | |
| 6 } | |
| 7 </style> | |
| 8 | |
| 9 <script src="../../../resources/testharness.js"></script> | |
| 10 <script src="../../../resources/testharnessreport.js"></script> | |
| 11 <script> | |
| 12 var numCallsScroll = 0; | |
| 13 var numCallsResize = 0; | |
| 14 var pageScaleFactor = 2; | |
| 15 | |
| 16 function viewport() { | |
| 17 return window.visualViewport; | |
| 18 } | |
| 19 | |
| 20 var t = async_test('verify that the scroll and resize events get fired on wind ow.visualViewport'); | |
| 21 | |
| 22 function verifySetViewportOffsets() { | |
| 23 // Set viewport offset. | |
| 24 window.visualViewport.scrollTop = 20; | |
| 25 requestAnimationFrame(function() { | |
| 26 assert_equals(numCallsScroll, 2); | |
| 27 assert_equals(numCallsResize, 1); | |
| 28 window.visualViewport.scrollLeft = 0; | |
| 29 requestAnimationFrame(function() { | |
| 30 assert_equals(numCallsScroll, 3); | |
| 31 assert_equals(numCallsResize, 1); | |
| 32 t.done(); | |
| 33 }); | |
| 34 }); | |
| 35 } | |
| 36 | |
| 37 window.onload = t.step_func(function() { | |
| 38 // Turn off smooth scrolling. | |
| 39 internals.settings.setScrollAnimatorEnabled(false); | |
| 40 | |
| 41 window.visualViewport.addEventListener('scroll', function(e) { | |
| 42 numCallsScroll++; | |
| 43 }); | |
| 44 | |
| 45 window.visualViewport.addEventListener('resize', function(e) { | |
| 46 numCallsResize++; | |
| 47 }); | |
| 48 | |
| 49 // Scroll both viewports. | |
| 50 eventSender.mouseMoveTo(100, 100); | |
| 51 eventSender.continuousMouseScrollBy(100, 100); | |
| 52 assert_equals(numCallsScroll, 0); | |
| 53 assert_equals(numCallsResize, 0); | |
| 54 | |
| 55 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser | |
| 56 // zoom below. This will be required to upstream to w3c repo. | |
| 57 internals.setPageScaleFactor(pageScaleFactor); | |
|
bokan
2016/06/24 21:52:36
Please split up this test into a scroll test and a
ymalik
2016/06/27 14:10:01
We will always have to use internals to scale then
bokan
2016/06/27 14:17:03
My comment above was about splitting this test int
| |
| 58 | |
| 59 // Verify viewport dimensions exclude scrollbar. | |
| 60 requestAnimationFrame(function() { | |
| 61 assert_equals(numCallsScroll, 0); | |
| 62 assert_equals(numCallsResize, 1); | |
| 63 internals.setVisualViewportOffset(10, 10); | |
| 64 requestAnimationFrame(function() { | |
| 65 assert_equals(numCallsScroll, 1); | |
| 66 assert_equals(numCallsScroll, 1); | |
| 67 verifySetViewportOffsets(); | |
| 68 }); | |
| 69 }); | |
| 70 }); | |
| 71 </script> | |
| OLD | NEW |