forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathsprite-sheet-image-draw.html
More file actions
55 lines (51 loc) · 2.05 KB
/
sprite-sheet-image-draw.html
File metadata and controls
55 lines (51 loc) · 2.05 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
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<meta name="fuzzy" content="maxDifference=0-1;totalPixels=14400-14600" />
<style>
.box {
width: 200px;
height: 50px;
display: inline-block;
zoom: 2;
image-rendering: crisp-edges;
}
.image-background {
background-position: 0px -16500px;
}
</style>
<body>
<div class="box image-background"></div>
<script>
(function() {
if (window.internals && window.testRunner) {
internals.clearMemoryCache();
internals.settings.setWebkitImageReadyEventEnabled(true);
internals.settings.setLargeImageAsyncDecodingEnabled(true);
testRunner.waitUntilDone();
}
var image = new Image();
image.onload = function() {
// Force async image decoding for this image.
if (window.internals)
internals.setAsyncDecodingEnabledForTesting(image, true);
// Change the background of the element.
var element = document.getElementsByClassName("image-background")[0];
element.style.backgroundImage = 'url(' + image.src + ')';
if (window.internals && window.testRunner) {
// Force layout and display so the image frame starts decoding.
document.body.offsetHeight;
testRunner.display();
// Wait for the image frame to finish decoding before finishing the test.
element.addEventListener("webkitImageFrameReady", function() {
// Ensure internals.destroyDecodedDataForAllImages() will not destroy
// the image's decoded data because it is inside the viewport.
internals.destroyDecodedDataForAllImages();
testRunner.notifyDone();
}, false);
}
}
image.src = "resources/sprite-sheet-red-green-blue.png";
})();
</script>
</body>
</html>