Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/dom/viewport/visualviewportchanged-event-fired.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/dom/viewport/visualviewportchanged-event-fired.html b/third_party/WebKit/LayoutTests/fast/dom/viewport/visualviewportchanged-event-fired.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9d81887492fac8fe8052cc82ef1257eee4bc0c7a |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/dom/viewport/visualviewportchanged-event-fired.html |
| @@ -0,0 +1,64 @@ |
| +<!DOCTYPE html> |
| +<script src="../../../resources/js-test.js"></script> |
| +<style> |
| + body { |
| + height: 2000px; |
| + width: 2000px; |
| + } |
| +</style> |
| + |
| +<script> |
| + window.jsTestIsAsync = true; |
| + var numCalls = 0; |
| + |
| + description("This test verifies that that visualviewportchanged event gets \ |
| + fired when the visual viewport is scaled or scrolled."); |
| + |
| + function verifySetViewportOffsets() { |
| + // Set viewport offset. Listener called twice. |
| + document.visualViewport.scrollTop = 20; |
| + requestAnimationFrame(function() { |
| + shouldBe("numCalls", "3"); |
| + document.visualViewport.scrollLeft = 0; |
| + requestAnimationFrame(function() { |
| + shouldBe("numCalls", "4"); |
| + finishJSTest(); |
| + }); |
| + }); |
| + } |
| + |
| + function runTest() { |
| + if (!window.eventSender || !window.internals) { |
| + finishJSTest(); |
| + return; |
| + } |
| + // Turn off smooth scrolling. |
| + internals.settings.setScrollAnimatorEnabled(false); |
| + |
| + document.addEventListener('visualviewportchanged', function(e) { |
| + numCalls++; |
| + }); |
| + |
| + // visualviewportchanged is non-bubbling. |
| + document.documentElement.addEventListener('visualviewportchanged', function(event) { |
| + debug("visualviewportchanged erroneously called on document"); |
| + }) |
| + |
| + // Scroll both viewports. Listner not called. |
|
bokan
2016/03/22 18:30:29
Check this in a rAF too please. Right now it could
ymalik
2016/03/22 21:28:19
Spoke to you offline. Don't need rAFs
|
| + eventSender.mouseMoveTo(100, 100); |
| + eventSender.continuousMouseScrollBy(100, 100); |
| + |
| + // Scale and scroll visual viewport. Listener called twice. |
| + internals.setPageScaleFactor(2); |
| + requestAnimationFrame(function() { |
| + shouldBe("numCalls", "1"); |
| + internals.setVisualViewportOffset(10, 10); |
| + requestAnimationFrame(function() { |
| + shouldBe("numCalls", "2"); |
| + verifySetViewportOffsets(); |
| + }); |
| + }); |
| + } |
| +</script> |
| + |
| +<body onload="runTest()"></body> |