imagebitmap: Resolve promise with ImageBitmap on bitmap task source (#37488)

Follow the ImageBitmap specification and use the global scope bitmap
task source
to fulfill resolved promise (asynchronously). 
https://html.spec.whatwg.org/multipage/#bitmap-task-source

Any promise rejection must be done synchronously.

Testing: Improvements in the following WPT test
-
html/canvas/element/manual/imagebitmap/createImageBitmap-resolves-in-task.any.js

Fixes (partially): #34112

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
Andrei Volykhin 2025-06-17 11:19:32 +03:00 committed by GitHub
parent ef5e9b5f4d
commit 1bd8f38810
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 30 deletions

View file

@ -22,6 +22,8 @@ use crate::task_manager::TaskManager;
/// doesn't implement TaskSource.
#[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, PartialEq, VariantArray)]
pub(crate) enum TaskSourceName {
/// <https://html.spec.whatwg.org/multipage/#bitmap-task-source>
Bitmap,
Canvas,
Clipboard,
DOMManipulation,
@ -48,6 +50,7 @@ pub(crate) enum TaskSourceName {
impl From<TaskSourceName> for ScriptThreadEventCategory {
fn from(value: TaskSourceName) -> Self {
match value {
TaskSourceName::Bitmap => ScriptThreadEventCategory::ScriptEvent,
TaskSourceName::Canvas => ScriptThreadEventCategory::ScriptEvent,
TaskSourceName::Clipboard => ScriptThreadEventCategory::ScriptEvent,
TaskSourceName::DOMManipulation => ScriptThreadEventCategory::ScriptEvent,