diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/htmlscriptelement.rs | 2 | ||||
-rw-r--r-- | components/script/script_module.rs | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 6b55cf0f220..86a803648a5 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -1053,7 +1053,7 @@ impl HTMLScriptElement { if let Some(record) = record { rooted!(in(*GlobalScope::get_cx()) let mut rval = UndefinedValue()); let evaluated = - module_tree.execute_module(global, record, rval.handle_mut().into()); + module_tree.execute_module(global, record, rval.handle_mut().into(), can_gc); if let Err(exception) = evaluated { module_tree.set_rethrow_error(exception); diff --git a/components/script/script_module.rs b/components/script/script_module.rs index 86b7134adc7..14c85722512 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -389,7 +389,7 @@ impl ModuleTree { &owner.global(), Some(ModuleHandler::new_boxed(Box::new( task!(fetched_resolve: move || { - this.finish_dynamic_module(identity, module_id); + this.finish_dynamic_module(identity, module_id, CanGc::note()); }), ))), None, @@ -451,6 +451,8 @@ impl ModuleTree { #[allow(unsafe_code, clippy::too_many_arguments)] /// <https://html.spec.whatwg.org/multipage/#creating-a-module-script> /// Step 7-11. + /// Although the CanGc argument appears unused, it represents the GC operations that + /// can occur as part of compiling a script. fn compile_module_script( &self, global: &GlobalScope, @@ -460,6 +462,7 @@ impl ModuleTree { options: ScriptFetchOptions, mut module_script: RustMutableHandleObject, inline: bool, + _can_gc: CanGc, ) -> Result<(), RethrowError> { let cx = GlobalScope::get_cx(); let _ac = JSAutoRealm::new(*cx, *global.reflector().get_jsobject()); @@ -540,12 +543,16 @@ impl ModuleTree { } } + /// Execute the provided module, storing the evaluation return value in the provided + /// mutable handle. Although the CanGc appears unused, it represents the GC operations + /// possible when evluating arbitrary JS. #[allow(unsafe_code)] pub fn execute_module( &self, global: &GlobalScope, module_record: HandleObject, eval_result: MutableHandleValue, + _can_gc: CanGc, ) -> Result<(), RethrowError> { let cx = GlobalScope::get_cx(); let _ac = JSAutoRealm::new(*cx, *global.reflector().get_jsobject()); @@ -1000,10 +1007,11 @@ impl ModuleOwner { #[allow(unsafe_code)] /// <https://html.spec.whatwg.org/multipage/#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):fetch-an-import()-module-script-graph> /// Step 6-9 - pub fn finish_dynamic_module( + fn finish_dynamic_module( &self, module_identity: ModuleIdentity, dynamic_module_id: DynamicModuleId, + can_gc: CanGc, ) { let global = self.global(); @@ -1029,7 +1037,7 @@ impl ModuleOwner { if let Some(record) = record { let evaluated = module_tree - .execute_module(&global, record, rval.handle_mut().into()) + .execute_module(&global, record, rval.handle_mut().into(), can_gc) .err(); if let Some(exception) = evaluated.clone() { @@ -1219,6 +1227,7 @@ impl FetchResponseListener for ModuleContext { self.options.clone(), compiled_module.handle_mut(), false, + CanGc::note(), ); match compiled_module_result { @@ -1790,6 +1799,7 @@ pub(crate) fn fetch_inline_module_script( options.clone(), compiled_module.handle_mut(), true, + can_gc, ); match compiled_module_result { |