mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision 0ed072539aa45d3a5a67c9164b243d27873f257c
This commit is contained in:
parent
0954871992
commit
e613cfd108
76 changed files with 1109 additions and 703 deletions
|
@ -12,3 +12,34 @@ class ElementLoadPromise {
|
|||
return document.getElementById(this.element_id);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns if the image is complete and the lazily loaded image matches the expected image.
|
||||
function is_image_fully_loaded(image, expected_image) {
|
||||
if (!image.complete || !expected_image.complete) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (image.width != expected_image.width ||
|
||||
image.height != expected_image.height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let canvas = document.createElement('canvas');
|
||||
canvas.width = image.width;
|
||||
canvas.height = image.height;
|
||||
let canvasContext = canvas.getContext("2d");
|
||||
canvasContext.save();
|
||||
canvasContext.drawImage(image, 0, 0);
|
||||
let data = canvasContext.getImageData(0, 0, canvas.width, canvas.height).data;
|
||||
|
||||
canvasContext.restore();
|
||||
canvasContext.drawImage(expected_image, 0, 0);
|
||||
let expected_data = canvasContext.getImageData(0, 0, canvas.width, canvas.height).data;
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i] != expected_data[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue