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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/viewport/visualviewportchanged-event-fired.html

Issue 1814013002: Visual viewport API initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/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..408273c15cf5f4b887406773c9210ee302087c60
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/viewport/visualviewportchanged-event-fired.html
@@ -0,0 +1,60 @@
+<!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++;
+ });
+
+ // Scroll both viewports. Listner not called.
+ eventSender.mouseMoveTo(100, 100);
+ eventSender.continuousMouseScrollBy(100, 100);
+ shouldBe("numCalls", "0");
+
+ // 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>

Powered by Google App Engine
This is Rietveld 408576698