Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/inspector-protocol/device-scale-not-persistant.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/device-scale-not-persistant.html b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/device-scale-not-persistant.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c1218e6f2df8c332b015785cc102ec5bdfa395dc |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/device-scale-not-persistant.html |
| @@ -0,0 +1,84 @@ |
| +<html> |
|
dgozman
2016/12/13 20:56:10
Let's put this under inspector-protocol/emulation.
allada
2016/12/14 19:50:47
Done.
|
| +<head> |
| +<script src="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 => InspectorTest.log("Used Image: " + src)); |
| + } |
| + |
| + 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" /> |
|
dgozman
2016/12/13 20:56:11
Let's only use resources under respective top-leve
allada
2016/12/14 19:50:47
Done.
|
| +</body> |
| +</html> |