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

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: review comments Created 4 years, 9 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..00c837124f3c7b251507687aa8e7dbfa16e8d5cb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/viewport/visualviewportchanged-event-fired.html
@@ -0,0 +1,53 @@
+<!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 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.
bokan 2016/03/22 21:34:21 I don't think you need this, document is above doc
ymalik 2016/03/23 00:13:44 Done.
+ document.documentElement.addEventListener('visualviewportchanged', function(event) {
+ debug("visualviewportchanged erroneously called on document");
+ })
+
+ // Scroll both viewports. Listner not called.
+ eventSender.mouseMoveTo(100, 100);
+ eventSender.continuousMouseScrollBy(100, 100);
bokan 2016/03/22 21:34:21 check numCalls == 0 here.
ymalik 2016/03/23 00:13:44 Done.
+
+ // Scale and scroll visual viewport. Listener called twice.
+ internals.setPageScaleFactor(2);
+ shouldBe("numCalls", "1");
+ internals.setVisualViewportOffset(10, 10);
+ shouldBe("numCalls", "2");
+
+ // Set viewport offset. Listener called twice.
+ document.visualViewport.scrollTop = 20;
+ shouldBe("numCalls", "3");
+ document.visualViewport.scrollLeft = 0;
+ shouldBe("numCalls", "4");
+ finishJSTest();
+ }
+</script>
+
+<body onload="runTest()"></body>

Powered by Google App Engine
This is Rietveld 408576698