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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.html

Issue 2570733002: [Devtools] Fixed devtools altering srcset image after close (Closed)
Patch Set: changes Created 4 years 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: 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>

Powered by Google App Engine
This is Rietveld 408576698