-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
Tests/LibWeb/Text/expected/HTML/image-bitmap-from-invalid-types-no-crash.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
49 changes: 49 additions & 0 deletions
49
Tests/LibWeb/Text/input/HTML/image-bitmap-from-invalid-types-no-crash.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters