Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
|
dgozman
2016/12/13 20:56:10
Let's put this under inspector-protocol/emulation.
allada
2016/12/14 19:50:47
Done.
| |
| 2 <head> | |
| 3 <script src="inspector-protocol-test.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 => InspectorTest.log("Used Image: " + s rc)); | |
| 46 } | |
| 47 | |
| 48 var initialImage; | |
| 49 | |
| 50 // Test chain functions. | |
| 51 collectMetrics(); | |
| 52 | |
| 53 function collectMetrics() | |
| 54 { | |
| 55 getSrcsetImage().then(src => initialImage = src).then(setLowResScaleFact or); | |
| 56 } | |
| 57 | |
| 58 function setLowResScaleFactor() | |
| 59 { | |
| 60 setScaleFactor(1).then(reloadPage).then(dumpImageSrc).then(setHighResSca leFactor); | |
| 61 } | |
| 62 | |
| 63 function setHighResScaleFactor() | |
| 64 { | |
| 65 setScaleFactor(2).then(reloadPage).then(dumpImageSrc).then(clearOverride ); | |
| 66 } | |
| 67 | |
| 68 function clearOverride() | |
| 69 { | |
| 70 clearScaleFactor().then(reloadPage).then(getSrcsetImage).then(value => { | |
| 71 var initImageEqCurrentImg = initialImage === value ? "Yes" : "No"; | |
| 72 InspectorTest.log("Current image src equal initial image: " + initIm ageEqCurrentImg); | |
| 73 InspectorTest.completeTest(); | |
| 74 }); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 </script> | |
| 79 </head> | |
| 80 <body onload="runTest()"> | |
| 81 <p>Test that srcset does not use wrong image when override scalefactor and then disabled.</p> | |
| 82 <img id="image-test" src="../../resources/square.png" srcset="../../resources/sq uare.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.
| |
| 83 </body> | |
| 84 </html> | |
| OLD | NEW |