Index: LayoutTests/fast/hidpi/resources/srcset-helper.js |
diff --git a/LayoutTests/fast/hidpi/resources/srcset-helper.js b/LayoutTests/fast/hidpi/resources/srcset-helper.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..703b266e967682203b850d9759ac3870c624b9db |
--- /dev/null |
+++ b/LayoutTests/fast/hidpi/resources/srcset-helper.js |
@@ -0,0 +1,29 @@ |
+function runTest() { |
+ if (!window.testRunner || !window.sessionStorage) |
+ return; |
+ |
+ if (!window.targetScaleFactor) |
+ window.targetScaleFactor = 2; |
+ |
+ if (!sessionStorage.scaleFactorIsSet) { |
+ testRunner.waitUntilDone(); |
+ testRunner.setBackingScaleFactor(targetScaleFactor, scaleFactorIsSet); |
+ } |
+ |
+ if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) { |
+ delete sessionStorage.pageReloaded; |
+ delete sessionStorage.scaleFactorIsSet; |
+ testRunner.notifyDone(); |
+ } else { |
+ // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor, |
+ // so to work around that, we must reload the page to get the new image. |
+ sessionStorage.pageReloaded = true; |
+ document.location.reload(true); |
+ } |
+} |
+ |
+function scaleFactorIsSet() { |
+ sessionStorage.scaleFactorIsSet = true; |
+} |
+ |
+window.addEventListener("load", runTest, false); |