REGRESSION (r179357-r179359): WebContent Crash using AOL Mail @ com.apple.JavascriptC...
[WebKit-https.git] / LayoutTests / resources / srcset-helper.js
1 window.addEventListener("load", function () {
2     if (!window.testRunner || !window.sessionStorage)
3         return;
4
5     if (!window.targetScaleFactor)
6         window.targetScaleFactor = 2;
7
8     var needsBackingScaleFactorChange = window.targetScaleFactor != 1 && !sessionStorage.pageReloaded;
9
10     if (needsBackingScaleFactorChange) {
11         testRunner.waitUntilDone();
12         testRunner.setBackingScaleFactor(targetScaleFactor, function() {
13             // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
14             // so to work around that, we must reload the page to get the new image.
15             sessionStorage.pageReloaded = true;
16             setTimeout(function() { document.location.reload(true) }, 0);
17         });
18         return;
19     }
20
21     try {
22         if (window.runTest)
23             runTest();
24     } catch (ex) {
25         testFailed("Uncaught exception" + ex);
26     }
27
28     var didReload = sessionStorage.pageReloaded;
29     delete sessionStorage.pageReloaded;
30
31     if (didReload)
32         testRunner.notifyDone();
33 });