From aab5a9e944f8b1c1a9de321047556bbcaa282a56 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Wed, 9 Oct 2024 16:11:51 +0200 Subject: [PATCH] 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 --- ...age-bitmap-from-invalid-types-no-crash.txt | 7 +++ ...ge-bitmap-from-invalid-types-no-crash.html | 49 +++++++++++++++++++ .../LibWeb/HTML/WindowOrWorkerGlobalScope.cpp | 1 + 3 files changed, 57 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/HTML/image-bitmap-from-invalid-types-no-crash.txt create mode 100644 Tests/LibWeb/Text/input/HTML/image-bitmap-from-invalid-types-no-crash.html diff --git a/Tests/LibWeb/Text/expected/HTML/image-bitmap-from-invalid-types-no-crash.txt b/Tests/LibWeb/Text/expected/HTML/image-bitmap-from-invalid-types-no-crash.txt new file mode 100644 index 00000000000..43be68f8969 --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/image-bitmap-from-invalid-types-no-crash.txt @@ -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 diff --git a/Tests/LibWeb/Text/input/HTML/image-bitmap-from-invalid-types-no-crash.html b/Tests/LibWeb/Text/input/HTML/image-bitmap-from-invalid-types-no-crash.html new file mode 100644 index 00000000000..4d9bb8a276d --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/image-bitmap-from-invalid-types-no-crash.html @@ -0,0 +1,49 @@ + + diff --git a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp index 512657240ce..d7990d99877 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp @@ -245,6 +245,7 @@ JS::NonnullGCPtr 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.