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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/viewport/viewport-dimensions-under-browser-zoom.html

Issue 1905693003: Update visual viewport API to take browser zoom into account. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments % cleanup 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/VisualViewport.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/dom/viewport/viewport-dimensions-under-browser-zoom.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/viewport/viewport-dimensions-under-browser-zoom.html b/third_party/WebKit/LayoutTests/fast/dom/viewport/viewport-dimensions-under-browser-zoom.html
new file mode 100644
index 0000000000000000000000000000000000000000..7b0d2130ba2c05c7c795a45562cb6c52867f9f70
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/viewport/viewport-dimensions-under-browser-zoom.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+</style>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+ var browserZoomFactor = 1.25;
+
+ test(function() {
+ window.scrollTo(100, 100);
+
+ // 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(2);
+
+ // Offset visual viewport by 10px.
+ document.visualViewport.scrollTop = 10;
+ document.visualViewport.scrollLeft = 10;
+
+ assert_equals(document.visualViewport.scrollTop, 10);
+ assert_equals(document.visualViewport.scrollLeft, 10);
+ assert_equals(document.visualViewport.clientWidth, 400);
+ assert_equals(document.visualViewport.clientHeight, 300);
+ assert_equals(document.visualViewport.pageScale, 2);
+
+ // Apply browser zoom.
+ window.internals.setZoomFactor(browserZoomFactor);
+
+ // Visual viewport dimensions should be scaled by the browser zoom factor.
+ assert_equals(document.visualViewport.scrollTop, 10 / browserZoomFactor);
+ assert_equals(document.visualViewport.scrollLeft, 10 / browserZoomFactor);
+ assert_equals(document.visualViewport.clientWidth, 400 / browserZoomFactor);
+ assert_equals(document.visualViewport.clientHeight, 300 / browserZoomFactor);
+ assert_equals(document.visualViewport.pageScale, 2);
+
+ // Verify setting the visual viewport offset under browser zoom.
+ document.visualViewport.scrollTop = 12.5;
+ document.visualViewport.scrollLeft = 12.5;
+ assert_equals(document.visualViewport.scrollTop, 12.5);
+ assert_equals(document.visualViewport.scrollLeft, 12.5);
+ assert_equals(document.visualViewport.clientWidth, 400 / browserZoomFactor);
+ assert_equals(document.visualViewport.clientHeight, 300 / browserZoomFactor);
+ assert_equals(document.visualViewport.pageScale, 2);
+ }, 'Verify viewport dimensions under bowser zoom.');
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/VisualViewport.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698