LibWeb: Reject Promise in createImageBitmap for Not Implemented Types

If we don't reject the Promise, it lasts forever,
so rejecting non implemented Promises is essential,
to not timeout in e.g. WPT tests
This commit is contained in:
Totto16 2024-10-09 16:11:51 +02:00 committed by Sam Atkins
commit aab5a9e944
Notes: github-actions[bot] 2024-10-09 16:47:24 +00:00
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,49 @@
<script src="../include.js"></script>
<script>
let canvas = document.createElement("canvas");
canvas.width = 20;
canvas.height = 20;
let ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(255, 0, 0)";
ctx.fillRect(0, 0, 10, 10);
let imageData = ctx.getImageData(0, 0, 20, 20);
let img = document.createElement("img");
let svgImg = document.createElement("img");
svgImg = document.createElementNS("http://www.w3.org/2000/svg", "image");
let video = document.createElement("video");
let file = new Blob([
new Uint8Array([
255, 10, 8, 16, 0, 9, 8, 6, 1, 0, 40, 0, 75, 56, 73, 152, 108, 128, 253, 145, 96, 0,
]),
]);
let imageBitmap = createImageBitmap(file, 0, 0, 0, 0);
const types = [
[file, "Blob"],
[imageData, "ImageData"],
[img, "HTMLImageElement"],
[svgImg, "SVGImageElement"],
[canvas, "HTMLCanvasElement"],
[imageBitmap, "ImageBitmap"],
[video, "HTMLVideoElement"],
];
asyncTest(async done => {
for (const [type, name] of types) {
try {
const result = await createImageBitmap(type, 0, 0, 20, 20);
println(`${name.padEnd(17, " ")} [Success]: ${result}`);
} catch (err) {
println(`${name.padEnd(17, " ")} [ Error ]: ${err}`);
}
}
done();
});
</script>