Implement origin-clean algorithm for ImageBitmap.

This resolves #973.
This commit is contained in:
wolfbeast 2019-02-14 11:46:21 +01:00 committed by Roy Tam
commit 1cc92006b6
10 changed files with 143 additions and 60 deletions

View file

@ -270,13 +270,22 @@ function testSecurityErrors() {
}
function checkPromiseFailedWithSecurityError(p) {
return p.then( function(reason) { ok(false, "Did not get SecurityError with unclean source. ImageBitmap was created successfully."); },
function(reason) { if (reason == "SecurityError: The operation is insecure.") {
ok(true, reason);
}
else {
ok(false, "Did not get SecurityError with unclean source. Error Message: " + reason);
}});
return p.then(imageBitmap => {
ok(!!imageBitmap, "ImageBitmaps are always created");
const context = document.createElement("canvas").getContext("2d");
context.drawImage(imageBitmap, 0, 0);
try {
context.getImageData(0, 0, 1, 1);
ok(false, "Did not get SecurityError with unclean source. ImageBitmap was created successfully.");
} catch (ex) {
if (ex == "SecurityError: The operation is insecure.") {
ok(true, ex);
}
else {
ok(false, "Did not get SecurityError with unclean source. Error Message: " + ex);
}
}
});
}
return Promise.all([