forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrcset-helper.js
More file actions
33 lines (27 loc) · 1.06 KB
/
srcset-helper.js
File metadata and controls
33 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
window.addEventListener("load", function () {
if (!window.testRunner || !window.sessionStorage)
return;
if (!window.targetScaleFactor)
window.targetScaleFactor = 2;
var needsBackingScaleFactorChange = window.targetScaleFactor != 1 && !sessionStorage.pageReloaded;
if (needsBackingScaleFactorChange) {
testRunner.waitUntilDone();
testRunner.setBackingScaleFactor(targetScaleFactor, function() {
// 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;
setTimeout(function() { document.location.reload(true) }, 0);
});
return;
}
try {
if (window.runTest)
runTest();
} catch (ex) {
testFailed("Uncaught exception" + ex);
}
var didReload = sessionStorage.pageReloaded;
delete sessionStorage.pageReloaded;
if (didReload)
testRunner.notifyDone();
});