| Index: third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.html
|
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.html b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7e5fa26976049876b249c6866f62b4761e35aa9e
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.html
|
| @@ -0,0 +1,87 @@
|
| +<html>
|
| +<head>
|
| +<script src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
|
| +<script type="text/javascript">
|
| +
|
| +function getCurrentSrc()
|
| +{
|
| + return document.getElementById("image-test").currentSrc;
|
| +}
|
| +
|
| +function test()
|
| +{
|
| + function setScaleFactor(value)
|
| + {
|
| + InspectorTest.log("Set deviceScaleFactor: " + value);
|
| + return InspectorTest.sendCommandPromise("Emulation.setDeviceMetricsOverride", {
|
| + deviceScaleFactor: value,
|
| + width: 1,
|
| + height: 1,
|
| + mobile: false,
|
| + fitWindow: false
|
| + });
|
| + }
|
| +
|
| + function clearScaleFactor(value)
|
| + {
|
| + InspectorTest.log("Clear deviceScaleFactor");
|
| + return InspectorTest.sendCommandPromise("Emulation.clearDeviceMetricsOverride", {});
|
| + }
|
| +
|
| + function reloadPage()
|
| + {
|
| + InspectorTest.log("Reloading Page");
|
| + return new Promise(success => InspectorTest.reloadProtocolTest(false, success));
|
| + }
|
| +
|
| + function getSrcsetImage()
|
| + {
|
| + var runInPage = InspectorTest.evaluateInInspectedPage;
|
| + return new Promise(success => runInPage("getCurrentSrc()", result => success(result.result.result.value)));
|
| + }
|
| +
|
| + function dumpImageSrc()
|
| + {
|
| + return getSrcsetImage().then(src => {
|
| + var relativeSrc = src.substring(src.lastIndexOf("/resources/"));
|
| + InspectorTest.log("Used Image: " + relativeSrc);
|
| + });
|
| + }
|
| +
|
| + var initialImage;
|
| +
|
| + // Test chain functions.
|
| + collectMetrics();
|
| +
|
| + function collectMetrics()
|
| + {
|
| + getSrcsetImage().then(src => initialImage = src).then(setLowResScaleFactor);
|
| + }
|
| +
|
| + function setLowResScaleFactor()
|
| + {
|
| + setScaleFactor(1).then(reloadPage).then(dumpImageSrc).then(setHighResScaleFactor);
|
| + }
|
| +
|
| + function setHighResScaleFactor()
|
| + {
|
| + setScaleFactor(2).then(reloadPage).then(dumpImageSrc).then(clearOverride);
|
| + }
|
| +
|
| + function clearOverride()
|
| + {
|
| + clearScaleFactor().then(reloadPage).then(getSrcsetImage).then(value => {
|
| + var initImageEqCurrentImg = initialImage === value ? "Yes" : "No";
|
| + InspectorTest.log("Current image src equal initial image: " + initImageEqCurrentImg);
|
| + InspectorTest.completeTest();
|
| + });
|
| + }
|
| +}
|
| +
|
| +</script>
|
| +</head>
|
| +<body onload="runTest()">
|
| +<p>Test that srcset does not use wrong image when override scalefactor and then disabled.</p>
|
| +<img id="image-test" src="../resources/square.png" srcset="../resources/square.png 1x, ../resources/square200.png 2x" />
|
| +</body>
|
| +</html>
|
|
|