diff --git a/Cargo.lock b/Cargo.lock index fb7c23b0523..5c5d082fdb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5240,7 +5240,7 @@ dependencies = [ [[package]] name = "mozjs" version = "0.14.1" -source = "git+https://github.com/servo/mozjs#4035b0c4e9e2df5cacc68c4b71e7375a48605902" +source = "git+https://github.com/servo/mozjs#913c2012ad14bd4e136bcf0b786320d4943f2a04" dependencies = [ "bindgen 0.71.1", "cc", @@ -5252,7 +5252,7 @@ dependencies = [ [[package]] name = "mozjs_sys" version = "0.128.13-3" -source = "git+https://github.com/servo/mozjs#4035b0c4e9e2df5cacc68c4b71e7375a48605902" +source = "git+https://github.com/servo/mozjs#913c2012ad14bd4e136bcf0b786320d4943f2a04" dependencies = [ "bindgen 0.71.1", "cc", diff --git a/components/script/devtools.rs b/components/script/devtools.rs index 945470194e2..eee7d311cc9 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -12,6 +12,7 @@ use devtools_traits::{ NodeInfo, NodeStyle, RuleModification, TimelineMarker, TimelineMarkerType, }; use ipc_channel::ipc::IpcSender; +use js::glue::IntroductionType; use js::jsval::UndefinedValue; use js::rust::ToString; use servo_config::pref; @@ -65,6 +66,7 @@ pub(crate) fn handle_evaluate_js( ScriptFetchOptions::default_classic_script(global), global.api_base_url(), can_gc, + IntroductionType::Undefined, ); if rval.is_undefined() { diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 7bdf949394b..857537badd7 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -14,6 +14,7 @@ use std::rc::Rc; use deny_public_fields::DenyPublicFields; use dom_struct::dom_struct; use fnv::FnvHasher; +use js::glue::IntroductionType; use js::jsapi::JS_GetFunctionObject; use js::jsval::JSVal; use js::rust::wrappers::CompileFunction; @@ -642,7 +643,12 @@ impl EventTarget { let cx = GlobalScope::get_cx(); let options = unsafe { - CompileOptionsWrapper::new(*cx, &handler.url.to_string(), handler.line as u32) + CompileOptionsWrapper::new( + *cx, + &handler.url.to_string(), + handler.line as u32, + IntroductionType::Undefined, + ) }; // Step 3.9, subsection Scope steps 1-6 diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index b2ab674e29d..14d63bbf849 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -28,7 +28,7 @@ use dom_struct::dom_struct; use embedder_traits::EmbedderMsg; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; -use js::glue::{IsWrapper, UnwrapObjectDynamic}; +use js::glue::{IntroductionType, IsWrapper, UnwrapObjectDynamic}; use js::jsapi::{ Compile1, CurrentGlobalOrNull, GetNonCCWObjectGlobal, HandleObject, Heap, InstantiateGlobalStencil, InstantiateOptions, JSContext, JSObject, JSScript, SetScriptPrivate, @@ -2768,6 +2768,7 @@ impl GlobalScope { fetch_options, script_base_url, can_gc, + IntroductionType::Undefined, ) } @@ -2783,6 +2784,7 @@ impl GlobalScope { fetch_options: ScriptFetchOptions, script_base_url: ServoUrl, can_gc: CanGc, + introduction_type: IntroductionType, ) -> bool { let cx = GlobalScope::get_cx(); @@ -2794,7 +2796,8 @@ impl GlobalScope { rooted!(in(*cx) let mut compiled_script = std::ptr::null_mut::()); match code { SourceCode::Text(text_code) => { - let options = CompileOptionsWrapper::new(*cx, filename, line_number); + let options = + CompileOptionsWrapper::new(*cx, filename, line_number, introduction_type); debug!("compiling dom string"); compiled_script.set(Compile1( diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 548791a8149..39cfdc3ac0c 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -18,6 +18,7 @@ use encoding_rs::Encoding; use html5ever::serialize::TraversalScope; use html5ever::{LocalName, Prefix, local_name, namespace_url, ns}; use ipc_channel::ipc; +use js::glue::IntroductionType; use js::jsval::UndefinedValue; use js::rust::{CompileOptionsWrapper, HandleObject, Stencil, transform_str_to_source_text}; use net_traits::http_status::HttpStatus; @@ -1111,6 +1112,11 @@ impl HTMLScriptElement { // Step 6. let document = self.owner_document(); let old_script = document.GetCurrentScript(); + let introduction_type = if script.external { + IntroductionType::Undefined + } else { + IntroductionType::InlineScript + }; match script.type_ { ScriptType::Classic => { @@ -1119,7 +1125,7 @@ impl HTMLScriptElement { } else { document.set_current_script(Some(self)) } - self.run_a_classic_script(&script, can_gc); + self.run_a_classic_script(&script, can_gc, introduction_type); document.set_current_script(old_script.as_deref()); }, ScriptType::Module => { @@ -1145,7 +1151,12 @@ impl HTMLScriptElement { } // https://html.spec.whatwg.org/multipage/#run-a-classic-script - pub(crate) fn run_a_classic_script(&self, script: &ScriptOrigin, can_gc: CanGc) { + pub(crate) fn run_a_classic_script( + &self, + script: &ScriptOrigin, + can_gc: CanGc, + introduction_type: IntroductionType, + ) { // TODO use a settings object rather than this element's document/window // Step 2 let document = self.owner_document(); @@ -1171,6 +1182,7 @@ impl HTMLScriptElement { script.fetch_options.clone(), script.url.clone(), can_gc, + introduction_type, ); } diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs index bf8febc8ad2..44a6c1e65be 100644 --- a/components/script/dom/userscripts.rs +++ b/components/script/dom/userscripts.rs @@ -4,6 +4,7 @@ use std::rc::Rc; +use js::glue::IntroductionType; use js::jsval::UndefinedValue; use script_bindings::root::DomRoot; @@ -39,6 +40,7 @@ pub(crate) fn load_script(head: &HTMLHeadElement) { ScriptFetchOptions::default_classic_script(global_scope), global_scope.api_base_url(), CanGc::note(), + IntroductionType::Undefined, ); } })); diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 82fefa1180b..d504eeea63b 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -17,6 +17,7 @@ use crossbeam_channel::Receiver; use devtools_traits::{DevtoolScriptControlMsg, WorkerId}; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; +use js::glue::IntroductionType; use js::jsval::UndefinedValue; use js::panic::maybe_resume_unwind; use js::rust::{HandleValue, MutableHandleValue, ParentRuntime}; @@ -433,6 +434,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope { url.as_str(), 1, rval.handle_mut(), + IntroductionType::Undefined, ); maybe_resume_unwind(); @@ -645,6 +647,7 @@ impl WorkerGlobalScope { self.worker_url.borrow().as_str(), 1, rval.handle_mut(), + IntroductionType::Undefined, ) { Ok(_) => (), Err(_) => { diff --git a/components/script/script_module.rs b/components/script/script_module.rs index 0c83195a2f9..c867f0816fe 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -16,6 +16,7 @@ use headers::{HeaderMapExt, ReferrerPolicy as ReferrerPolicyHeader}; use html5ever::local_name; use hyper_serde::Serde; use indexmap::{IndexMap, IndexSet}; +use js::glue::IntroductionType; use js::jsapi::{ CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport, GetModuleRequestSpecifier, GetModuleResolveHook, GetRequestedModuleSpecifier, GetRequestedModulesCount, @@ -468,11 +469,13 @@ impl ModuleTree { mut module_script: RustMutableHandleObject, inline: bool, can_gc: CanGc, + introduction_type: IntroductionType, ) -> Result<(), RethrowError> { let cx = GlobalScope::get_cx(); let _ac = JSAutoRealm::new(*cx, *global.reflector().get_jsobject()); - let compile_options = unsafe { CompileOptionsWrapper::new(*cx, url.as_str(), 1) }; + let compile_options = + unsafe { CompileOptionsWrapper::new(*cx, url.as_str(), 1, introduction_type) }; let mut module_source = ModuleSource { source: module_script_text, unminified_dir: global.unminified_js_dir(), @@ -1332,6 +1335,7 @@ impl FetchResponseListener for ModuleContext { compiled_module.handle_mut(), false, CanGc::note(), + IntroductionType::Undefined, ); match compiled_module_result { @@ -1896,6 +1900,7 @@ pub(crate) fn fetch_inline_module_script( compiled_module.handle_mut(), true, can_gc, + IntroductionType::InlineScript, ); match compiled_module_result {