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

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

Issue 2960023003: [DevTools] Migrate inspector-protocol/emulation tests to new harness (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.js b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.js
new file mode 100644
index 0000000000000000000000000000000000000000..206672e8c6dcbfaf7ac4495f8c1c2576f747bfd7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-scale-not-persistant.js
@@ -0,0 +1,52 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.startURL('../resources/device-scale-not-persistant.html',
+ 'Test that srcset does not use wrong image when override scalefactor and then disabled.');
+
+ function getSrcsetImage() {
+ return session.evaluate(`document.getElementById('image-test').currentSrc`);
+ }
+
+ async function setScaleFactor(value) {
+ testRunner.log('Set deviceScaleFactor: ' + value);
+ await dp.Emulation.setDeviceMetricsOverride({
+ deviceScaleFactor: value,
+ width: 1,
+ height: 1,
+ mobile: false,
+ fitWindow: false
+ });
+ }
+
+ async function reloadPage() {
+ testRunner.log('Reloading Page');
+ dp.Page.reload();
+ await dp.Page.onceLoadEventFired();
+ testRunner.log('\nPage reloaded.\n');
+ }
+
+ async function dumpImageSrc() {
+ var src = await getSrcsetImage();
+ var relativeSrc = src.substring(src.lastIndexOf('/resources/'));
+ testRunner.log('Used Image: ' + relativeSrc);
+ }
+
+ dp.Page.enable();
+ var initialImage = await getSrcsetImage();
+
+ await setScaleFactor(1);
+ await reloadPage();
+ await dumpImageSrc();
+
+ await setScaleFactor(2);
+ await reloadPage();
+ await dumpImageSrc();
+
+ testRunner.log('Clear deviceScaleFactor');
+ await dp.Emulation.clearDeviceMetricsOverride();
+ await reloadPage();
+ var value = await getSrcsetImage();
+ var initImageEqCurrentImg = initialImage === value ? 'Yes' : 'No';
+ testRunner.log('Current image src equal initial image: ' + initImageEqCurrentImg);
+
+ testRunner.completeTest();
+})

Powered by Google App Engine
This is Rietveld 408576698