mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
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:
parent
a8788e5abb
commit
aab5a9e944
Notes:
github-actions[bot]
2024-10-09 16:47:24 +00:00
Author: https://github.com/Totto16
Commit: aab5a9e944
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1700
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 57 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
|||
Blob [Success]: [object ImageBitmap]
|
||||
ImageData [ Error ]: Error: Not Implemented: createImageBitmap() for non-blob types
|
||||
HTMLImageElement [ Error ]: TypeError: No union types matched
|
||||
SVGImageElement [ Error ]: TypeError: No union types matched
|
||||
HTMLCanvasElement [ Error ]: TypeError: No union types matched
|
||||
ImageBitmap [ Error ]: TypeError: No union types matched
|
||||
HTMLVideoElement [ Error ]: TypeError: No union types matched
|
|
@ -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>
|
|
@ -245,6 +245,7 @@ JS::NonnullGCPtr<JS::Promise> WindowOrWorkerGlobalScopeMixin::create_image_bitma
|
|||
dbgln("(STUBBED) createImageBitmap() for non-blob types");
|
||||
(void)sx;
|
||||
(void)sy;
|
||||
p->reject(JS::Error::create(relevant_realm(*p), "Not Implemented: createImageBitmap() for non-blob types"sv));
|
||||
});
|
||||
|
||||
// 7. Return p.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue