Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-visual-viewport-size.html |
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-visual-viewport-size.html b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-visual-viewport-size.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..110379aaad8c96315473b6780ef695e0d79c7b44 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-visual-viewport-size.html |
| @@ -0,0 +1,118 @@ |
| +<html> |
| +<head> |
| + |
| +<script src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script> |
| + |
| +<style> |
| +body { |
| + margin: 0; |
| + overflow: hidden; |
| + min-height: 1000px; |
| +} |
| + |
| +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, |
|
dgozman
2016/07/21 20:54:08
I don't like that override we use is observable by
Eric Seckler
2016/07/22 14:44:48
I noted some of this in the design doc. I think we
|
| + layoutHeight: document.getElementById("layoutViewportDiv").clientHeight |
| + }, null, 4); |
| +} |
| + |
| +function test() |
| +{ |
| + function printMetrics(callback) |
| + { |
| + InspectorTest.evaluateInPage("dumpMetrics()", print); |
| + |
| + function print(metrics) |
| + { |
| + InspectorTest.log(metrics); |
| + callback(); |
| + } |
| + } |
| + |
| + function testOverrides(width, height, visualWidth, visualHeight, next) |
| + { |
| + var params = { |
| + width: width, |
| + height: height, |
| + visualViewportWidth: visualWidth, |
| + visualViewportHeight: visualHeight, |
| + deviceScaleFactor: 0, |
| + mobile: false, |
| + fitWindow: false |
| + }; |
| + InspectorTest.log("Overrides: " + JSON.stringify(params)); |
| + |
| + InspectorTest.sendCommandOrDie("Emulation.setDeviceMetricsOverride", params, printMetrics.bind(null, overridesActive)); |
| + |
| + function overridesActive() |
| + { |
| + InspectorTest.log("Clearing overrides."); |
| + InspectorTest.sendCommandOrDie("Emulation.clearDeviceMetricsOverride", {}, printMetrics.bind(null, next)); |
| + } |
| + } |
| + |
| + InspectorTest.runTestSuite([ |
| + function noOverrides(next) |
| + { |
| + testOverrides(0, 0, 0, 0, next); |
| + }, |
| + |
| + function width(next) |
| + { |
| + testOverrides(200, 0, 0, 0, next); |
| + }, |
| + |
| + function height(next) |
| + { |
| + testOverrides(0, 200, 0, 0, next); |
| + }, |
| + |
| + function visualWidth(next) |
| + { |
| + testOverrides(0, 0, 100, 0, next); |
| + }, |
| + |
| + function visualHeight(next) |
| + { |
| + testOverrides(0, 0, 0, 100, next); |
| + }, |
| + |
| + function visualWidthAndHeight(next) |
| + { |
| + testOverrides(0, 0, 100, 150, next); |
| + }, |
| + |
| + function visualAndFrame(next) |
| + { |
| + testOverrides(200, 250, 100, 150, next); |
| + }, |
| + |
| + function visualLargerThanFrame(next) |
| + { |
| + testOverrides(100, 150, 200, 250, next); |
| + } |
| + ]); |
| +} |
| +</script> |
| + |
| +</head> |
| +<body onload="runTest()"> |
| +<div id="layoutViewportDiv"></div> |
| +<p> |
| +Tests overrides for visual viewport size in combination with frame size overrides. |
| +</p> |
| +</body> |
| +</html> |