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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override.html

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync, patch in 2169483002 (+ regression test), add DevTools tests. Created 4 years, 5 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/inspector-protocol/emulation/scroll-and-scale-override.html
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override.html b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override.html
new file mode 100644
index 0000000000000000000000000000000000000000..b0d418c9a0df08b3ad7e8272b80e4260f86da173
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override.html
@@ -0,0 +1,167 @@
+<html>
+<head>
+
+<script src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+
+<style>
+body {
+ margin: 0;
+ overflow: hidden;
+ min-width: 2000px;
+ min-height: 10000px;
+}
+
+div#layoutViewportDiv {
+ position: fixed;
+ z-index: 100;
+ width: 100%;
+ height: 100%;
+}
+</style>
+
+<script>
+function dumpMetrics()
+{
+ return JSON.stringify({
+ visualWidth: window.innerWidth,
+ visualHeight: window.innerHeight,
+ layoutWidth: document.getElementById("layoutViewportDiv").clientWidth,
+ layoutHeight: document.getElementById("layoutViewportDiv").clientHeight,
+ scrollX: window.visualViewport.pageX - window.visualViewport.scrollLeft,
+ scrollY: window.visualViewport.pageY - window.visualViewport.scrollTop,
+ visualScrollX: window.visualViewport.scrollLeft,
+ visualScrollY: window.visualViewport.scrollTop,
+ visualScale: window.visualViewport.scale
+ }, null, 4);
+}
+
+function test()
+{
+ function printMetrics(callback)
+ {
+ InspectorTest.evaluateInPage("dumpMetrics()", print);
+
+ function print(metrics)
+ {
+ InspectorTest.log(metrics);
+ callback();
+ }
+ }
+
+ function testOverrides(width, height, visualWidth, visualHeight, scrollX, scrollY, visualX, visualY, visualScale, next)
+ {
+ var metricsParams = {
+ width: width,
+ height: height,
+ visualViewportWidth: visualWidth,
+ visualViewportHeight: visualHeight,
+ deviceScaleFactor: 0,
+ mobile: false,
+ fitWindow: false
+ };
+ var scrollParams = {
+ scrollPositionX: scrollX,
+ scrollPositionY: scrollY,
+ visualViewportPositionX: visualX,
+ visualViewportPositionY: visualY,
+ visualViewportScale: visualScale
+ };
+ InspectorTest.log("Device metrics overrides: " + JSON.stringify(metricsParams));
+ InspectorTest.log("Scroll/scale overrides: " + JSON.stringify(scrollParams));
+
+ InspectorTest.sendCommandOrDie("Emulation.setDeviceMetricsOverride", metricsParams, metricsOverrideActive);
+
+ function metricsOverrideActive()
+ {
+ InspectorTest.sendCommandOrDie("Emulation.setScrollAndScaleOverride", scrollParams, printMetrics.bind(null, allOverridesActive));
+ }
+
+ function allOverridesActive()
+ {
+ InspectorTest.log("Clearing overrides.");
+ InspectorTest.sendCommandOrDie("Emulation.clearScrollAndScaleOverride", {}, scrollOverrideCleared);
+
+ function scrollOverrideCleared()
+ {
+ InspectorTest.sendCommandOrDie("Emulation.clearDeviceMetricsOverride", {}, printMetrics.bind(null, next));
+ }
+ }
+ }
+
+ InspectorTest.runTestSuite([
+ function noOverrides(next)
+ {
+ testOverrides(0, 0, 0, 0, -1, -1, -1, -1, 0, next);
+ },
+
+ function frameScrollX(next)
+ {
+ testOverrides(400, 200, 0, 0, 200, -1, -1, -1, 0, next);
+ },
+
+ function frameScrollY(next)
+ {
+ testOverrides(400, 200, 0, 0, -1, 600, -1, -1, 0, next);
+ },
+
+ function frameScrollXWithResizedVisualViewport(next)
+ {
+ testOverrides(400, 200, 200, 100, 200, -1, -1, -1, 0, next);
+ },
+
+ function frameScrollYWithResizedVisualViewport(next)
+ {
+ testOverrides(400, 200, 200, 100, -1, 600, -1, -1, 0, next);
+ },
+
+ function visualScrollX(next)
+ {
+ testOverrides(400, 200, 200, 100, -1, -1, 100, -1, 0, next);
+ },
+
+ function visualScrollY(next)
+ {
+ testOverrides(400, 200, 200, 100, -1, -1, -1, 50, 0, next);
+ },
+
+ function visualScale(next)
+ {
+ testOverrides(400, 200, 200, 100, -1, -1, -1, -1, 2.0, next);
+ },
+
+ function visualScrollAndScale(next)
+ {
+ testOverrides(400, 200, 200, 100, -1, -1, 100, 50, 2.0, next);
+ },
+
+ function scrollFrameAndVisual(next)
+ {
+ testOverrides(400, 200, 200, 100, 200, 600, 100, 50, 0, next);
+ },
+
+ function scrollFrameAndVisualMax(next)
+ {
+ testOverrides(400, 200, 200, 100, 100000, 100000, 100000, 100000, 0, next);
+ },
+
+ function scrollAndScaleFrameAndVisual(next)
+ {
+ testOverrides(400, 200, 200, 100, 200, 600, 100, 50, 2.0, next);
+ },
+
+ function scrollAndScaleFrameAndVisualMax(next)
+ {
+ testOverrides(400, 200, 200, 100, 100000, 100000, 100000, 100000, 2.0, next);
+ },
+ ]);
+}
+</script>
+
+</head>
+<body onload="runTest()">
+<div id="layoutViewportDiv"></div>
+<p>
+Tests overrides for frame scroll position and visual viewport scroll position and scale.
+</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698