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

Unified Diff: LayoutTests/inspector/device-emulation/device-emulation-scale-only.html

Issue 205403004: [DevTools] Allow overriding only the device scale factor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase, one test fixed Created 6 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: LayoutTests/inspector/device-emulation/device-emulation-scale-only.html
diff --git a/LayoutTests/inspector/device-emulation/device-emulation-scale-only.html b/LayoutTests/inspector/device-emulation/device-emulation-scale-only.html
new file mode 100644
index 0000000000000000000000000000000000000000..f1f09f7658692c75076ff81acb8cbcea6d83d675
--- /dev/null
+++ b/LayoutTests/inspector/device-emulation/device-emulation-scale-only.html
@@ -0,0 +1,86 @@
+<html>
+<head>
+
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+
+<style>
+body {
+ margin: 0;
+ min-height: 1000px;
+}
+</style>
+
+<script>
+function dumpMetrics()
+{
+ return JSON.stringify({
+ screen: window.screen.width + "x" + window.screen.height,
+ position: window.screenX + "x" + window.screenY,
+ inner: window.innerWidth + "x" + window.innerHeight,
+ body: document.body.offsetWidth + "x" + document.body.offsetHeight,
+ dpr: window.devicePixelRatio
+ });
+}
+
+function test()
+{
+ function getPageMetrics(callback)
+ {
+ InspectorTest.evaluateInPage("dumpMetrics()", parse);
+
+ function parse(json)
+ {
+ callback(JSON.parse(json.value));
+ }
+ }
+
+ var initialMetrics;
+
+ function applyEmulationAndCheckMetrics(deviceScaleFactor, callback)
+ {
+ InspectorTest.addResult("Overriding device scale factor: " + deviceScaleFactor);
+ PageAgent.setDeviceMetricsOverride(0, 0, deviceScaleFactor, false, false, false, 1, getPageMetrics.bind(null, check));
+
+ function check(metrics)
+ {
+ if (metrics.screen !== initialMetrics.screen)
+ InspectorTest.addResult("Wrong screen size: " + metrics.screen + " instead of " + initialMetrics.screen);
+ if (metrics.position !== initialMetrics.position)
+ InspectorTest.addResult("Wrong screen position: " + metrics.position + " instead of " + initialMetrics.position);
+ if (metrics.inner !== initialMetrics.inner)
+ InspectorTest.addResult("Wrong window size: " + metrics.inner + " instead of " + initialMetrics.inner);
+ if (metrics.body !== initialMetrics.body)
+ InspectorTest.addResult("Wrong body size: " + metrics.body + " instead of " + initialMetrics.body);
+ if (deviceScaleFactor)
+ InspectorTest.addResult("Got device scale factor: " + metrics.dpr);
+ callback();
+ }
+ }
+
+ function saveInitialMetrics(callback)
+ {
+ getPageMetrics(save);
+
+ function save(metrics)
+ {
+ initialMetrics = metrics;
+ callback();
+ }
+ }
+
+ var complete = InspectorTest.completeTest.bind(InspectorTest);
+ var reset = applyEmulationAndCheckMetrics.bind(null, 0, complete);
+ var check3 = applyEmulationAndCheckMetrics.bind(null, 3, reset);
+ var check2 = applyEmulationAndCheckMetrics.bind(null, 2, check3);
+ var check1 = applyEmulationAndCheckMetrics.bind(null, 1, check2);
+ saveInitialMetrics(check1);
+}
+</script>
+
+</head>
+<body onload="runTest()">
+<p>
+Tests that overriding only device scale factor does not affect any other value.
+</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698