Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/viewport/scroll-resize-events-fired.html

Issue 2096783004: Seperate visualviewportchanged event into scroll and resize events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash + tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..56f8182d3615019e78263e52bb2ef7cce420e80c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/viewport/scroll-resize-events-fired.html
@@ -0,0 +1,79 @@
+<!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() {
+ t.step(function() {
+ assert_equals(numCallsScroll, 2, "scroll listener called for scrollTop");
+ assert_equals(numCallsResize, 1, "resize listener not called for scrollTop");
+ });
+ window.visualViewport.scrollLeft = 0;
+ requestAnimationFrame(function() {
+ t.step(function() {
+ assert_equals(numCallsScroll, 3, "scroll listener called for scrollLeft");
+ assert_equals(numCallsResize, 1, "resize listener not called for scrollLeft");
+ });
+ 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);
+
+ // Verify viewport dimensions exclude scrollbar.
+ requestAnimationFrame(function() {
+ t.step(function() {
+ assert_equals(numCallsScroll, 0, "scroll listener not called for scale");
+ assert_equals(numCallsResize, 1, "resize listener called for scale");
+ });
+ internals.setVisualViewportOffset(10, 10);
+ requestAnimationFrame(function() {
+ t.step(function() {
+ assert_equals(numCallsScroll, 1, "scroll listener called for offset change");
+ assert_equals(numCallsResize, 1, "resize listener not called for offset change");
+ });
+ verifySetViewportOffsets();
+ });
+ });
+ });
+</script>

Powered by Google App Engine
This is Rietveld 408576698