Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/dom/viewport/scroll-resize-events-fired.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/dom/viewport/scroll-resize-events-fired.html b/third_party/WebKit/LayoutTests/fast/dom/viewport/scroll-resize-events-fired.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5fcba8b464c10e6092a7cc0eb25250a870ee2fb2 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/dom/viewport/scroll-resize-events-fired.html |
| @@ -0,0 +1,71 @@ |
| +<!DOCTYPE html> |
| +<style> |
| + body { |
| + height: 2000px; |
| + width: 2000px; |
| + } |
| +</style> |
| + |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<script> |
| + var numCallsScroll = 0; |
| + var numCallsResize = 0; |
| + var pageScaleFactor = 2; |
| + |
| + function viewport() { |
| + return window.visualViewport; |
| + } |
| + |
| + var t = async_test('verify that the scroll and resize events get fired on window.visualViewport'); |
| + |
| + function verifySetViewportOffsets() { |
| + // Set viewport offset. |
| + window.visualViewport.scrollTop = 20; |
| + requestAnimationFrame(function() { |
| + assert_equals(numCallsScroll, 2); |
| + assert_equals(numCallsResize, 1); |
| + window.visualViewport.scrollLeft = 0; |
| + requestAnimationFrame(function() { |
| + assert_equals(numCallsScroll, 3); |
| + assert_equals(numCallsResize, 1); |
| + t.done(); |
| + }); |
| + }); |
| + } |
| + |
| + window.onload = t.step_func(function() { |
| + // Turn off smooth scrolling. |
| + internals.settings.setScrollAnimatorEnabled(false); |
| + |
| + window.visualViewport.addEventListener('scroll', function(e) { |
| + numCallsScroll++; |
| + }); |
| + |
| + window.visualViewport.addEventListener('resize', function(e) { |
| + numCallsResize++; |
| + }); |
| + |
| + // Scroll both viewports. |
| + eventSender.mouseMoveTo(100, 100); |
| + eventSender.continuousMouseScrollBy(100, 100); |
| + assert_equals(numCallsScroll, 0); |
| + assert_equals(numCallsResize, 0); |
| + |
| + // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser |
| + // zoom below. This will be required to upstream to w3c repo. |
| + 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
|
| + |
| + // Verify viewport dimensions exclude scrollbar. |
| + requestAnimationFrame(function() { |
| + assert_equals(numCallsScroll, 0); |
| + assert_equals(numCallsResize, 1); |
| + internals.setVisualViewportOffset(10, 10); |
| + requestAnimationFrame(function() { |
| + assert_equals(numCallsScroll, 1); |
| + assert_equals(numCallsScroll, 1); |
| + verifySetViewportOffsets(); |
| + }); |
| + }); |
| + }); |
| +</script> |