forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathdecoding-attribute-dynamic-async-small-image.html
More file actions
43 lines (39 loc) · 1.69 KB
/
decoding-attribute-dynamic-async-small-image.html
File metadata and controls
43 lines (39 loc) · 1.69 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
34
35
36
37
38
39
40
41
42
43
<body>
<p>This test ensures if the decoding attribute of an image is set dynamically to "async", the image will be decoded asynchronously regardless of its size.</p>
<img decoding="sync">
<script>
function loadImage(image, src) {
return new Promise((resolve) => {
image.onload = (() => {
if (window.internals && window.testRunner) {
// Force async image decoding for this image.
internals.setAsyncDecodingEnabledForTesting(image, true);
// Force layout and display so the image gets drawn.
document.body.offsetHeight;
testRunner.display();
// Listen for the webkitImageFrameReady event after requesting
// the image decoding.
image.addEventListener("webkitImageFrameReady", function() {
resolve();
}, false);
} else
resolve();
});
image.src = src;
});
}
(function() {
if (window.internals && window.testRunner) {
internals.clearMemoryCache();
internals.settings.setWebkitImageReadyEventEnabled(true);
testRunner.waitUntilDone();
}
var image = document.querySelector("img");
image.decoding="async";
loadImage(image, "resources/green-24x24.jpg", true).then(() => {
if (window.testRunner)
testRunner.notifyDone();
});
})();
</script>
</body>