|
2 | 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. |
4 | 4 |
|
5 | | -use crate::RuntimeMacroTask; |
6 | 5 | use andromeda_core::{Extension, ExtensionOp}; |
7 | | -use andromeda_core::{HostData, MacroTask}; |
8 | | -use nova_vm::engine::Global; |
9 | 6 | use nova_vm::{ |
10 | 7 | ecmascript::{ |
11 | 8 | builtins::ArgumentsList, |
@@ -49,13 +46,13 @@ impl WebExt { |
49 | 46 | Self::internal_performance_time_origin, |
50 | 47 | 0, |
51 | 48 | ), |
52 | | - ExtensionOp::new("queueMicrotask", Self::queue_microtask, 1), |
53 | 49 | ], |
54 | 50 | storage: None, |
55 | 51 | files: vec![ |
56 | 52 | include_str!("./event.ts"), |
57 | 53 | include_str!("./text_encoding.ts"), |
58 | 54 | include_str!("./performance.ts"), |
| 55 | + include_str!("./queueMicrotask.ts"), |
59 | 56 | ], |
60 | 57 | } |
61 | 58 | } |
@@ -422,53 +419,6 @@ impl WebExt { |
422 | 419 | .as_secs_f64() |
423 | 420 | * 1000.0 |
424 | 421 | }); |
425 | | - |
426 | 422 | Ok(Value::from_f64(agent, origin_ms, gc).unbind()) |
427 | 423 | } |
428 | | - |
429 | | - /// Implementation of queueMicrotask as per HTML specification: |
430 | | - /// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask |
431 | | - pub fn queue_microtask<'gc>( |
432 | | - agent: &mut Agent, |
433 | | - _this: Value, |
434 | | - args: ArgumentsList, |
435 | | - gc: GcScope<'gc, '_>, |
436 | | - ) -> JsResult<'gc, Value<'gc>> { |
437 | | - let callback = args.get(0); |
438 | | - let _: nova_vm::ecmascript::types::Function = match callback.try_into() { |
439 | | - Ok(function) => function, |
440 | | - Err(_) => { |
441 | | - return Err(agent |
442 | | - .throw_exception( |
443 | | - ExceptionType::TypeError, |
444 | | - "The callback provided as an argument to queueMicrotask must be a function.".to_string(), |
445 | | - gc.nogc(), |
446 | | - ) |
447 | | - .unbind()); |
448 | | - } |
449 | | - }; |
450 | | - |
451 | | - // TODO: Implement proper microtask queueing when Nova APIs become available |
452 | | - |
453 | | - // Store the callback globally so it can be called later |
454 | | - let root_callback = Global::new(agent, callback.unbind()); |
455 | | - |
456 | | - // Get host data to access the macro task system |
457 | | - let host_data = agent.get_host_data(); |
458 | | - let host_data: &HostData<RuntimeMacroTask> = host_data.downcast_ref().unwrap(); |
459 | | - let macro_task_tx = host_data.macro_task_tx(); |
460 | | - |
461 | | - // Schedule an immediate task to call the callback |
462 | | - // Using spawn_macro_task with an immediately resolving future |
463 | | - host_data.spawn_macro_task(async move { |
464 | | - // Send a macro task to call the callback |
465 | | - macro_task_tx |
466 | | - .send(MacroTask::User(RuntimeMacroTask::RunMicrotaskCallback( |
467 | | - root_callback, |
468 | | - ))) |
469 | | - .unwrap(); |
470 | | - }); |
471 | | - |
472 | | - Ok(Value::Undefined) |
473 | | - } |
474 | 424 | } |
0 commit comments