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

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

Issue 2960023003: [DevTools] Migrate inspector-protocol/emulation tests to new harness (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../http/tests/inspector-protocol/resources/inspector-protocol-te st.js"></script>
4 <script type="text/javascript">
5
6 function getCurrentSrc()
7 {
8 return document.getElementById("image-test").currentSrc;
9 }
10
11 function test()
12 {
13 function setScaleFactor(value)
14 {
15 InspectorTest.log("Set deviceScaleFactor: " + value);
16 return InspectorTest.sendCommandPromise("Emulation.setDeviceMetricsOverr ide", {
17 deviceScaleFactor: value,
18 width: 1,
19 height: 1,
20 mobile: false,
21 fitWindow: false
22 });
23 }
24
25 function clearScaleFactor(value)
26 {
27 InspectorTest.log("Clear deviceScaleFactor");
28 return InspectorTest.sendCommandPromise("Emulation.clearDeviceMetricsOve rride", {});
29 }
30
31 function reloadPage()
32 {
33 InspectorTest.log("Reloading Page");
34 return new Promise(success => InspectorTest.reloadProtocolTest(false, su ccess));
35 }
36
37 function getSrcsetImage()
38 {
39 var runInPage = InspectorTest.evaluateInInspectedPage;
40 return new Promise(success => runInPage("getCurrentSrc()", result => suc cess(result.result.result.value)));
41 }
42
43 function dumpImageSrc()
44 {
45 return getSrcsetImage().then(src => {
46 var relativeSrc = src.substring(src.lastIndexOf("/resources/"));
47 InspectorTest.log("Used Image: " + relativeSrc);
48 });
49 }
50
51 var initialImage;
52
53 // Test chain functions.
54 collectMetrics();
55
56 function collectMetrics()
57 {
58 getSrcsetImage().then(src => initialImage = src).then(setLowResScaleFact or);
59 }
60
61 function setLowResScaleFactor()
62 {
63 setScaleFactor(1).then(reloadPage).then(dumpImageSrc).then(setHighResSca leFactor);
64 }
65
66 function setHighResScaleFactor()
67 {
68 setScaleFactor(2).then(reloadPage).then(dumpImageSrc).then(clearOverride );
69 }
70
71 function clearOverride()
72 {
73 clearScaleFactor().then(reloadPage).then(getSrcsetImage).then(value => {
74 var initImageEqCurrentImg = initialImage === value ? "Yes" : "No";
75 InspectorTest.log("Current image src equal initial image: " + initIm ageEqCurrentImg);
76 InspectorTest.completeTest();
77 });
78 }
79 }
80
81 </script>
82 </head>
83 <body onload="runTest()">
84 <p>Test that srcset does not use wrong image when override scalefactor and then disabled.</p>
85 <img id="image-test" src="../resources/square.png" srcset="../resources/square.p ng 1x, ../resources/square200.png 2x" />
86 </body>
87 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698