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

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: Split off size override, address reviewer comments. 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b14bb2fd00a595c35459753381c043a62e3f3b38
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override.html
@@ -0,0 +1,171 @@
+<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 = {};
+ if (scrollX >= 0)
+ scrollParams['scrollPositionX'] = scrollX;
+ if (scrollY >= 0)
+ scrollParams['scrollPositionY'] = scrollY;
+ if (visualX >= 0)
+ scrollParams['visualViewportPositionX'] = visualX;
+ if (visualY >= 0)
+ scrollParams['visualViewportPositionY'] = visualY;
+ if (visualScale > 0)
+ scrollParams['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>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698