script: Set correct introductionType values in more places (#38550)

to use the [SpiderMonkey Debugger
API](https://firefox-source-docs.mozilla.org/js/Debugger/) as the single
source of truth about scripts and their sources for devtools purposes
(servo/servo#38334), we need to keep track of whether scripts come from
an actual file or from things like setTimeout(), because for some
[introductionType](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.Source.html#introductiontype)
[values](https://firefox-source-docs.mozilla.org/devtools-user/debugger-api/debugger.source/#accessor-properties-of-the-debugger-source-prototype-object),
we want to disregard the script unless it has a [`//# sourceURL=`
override](https://tc39.es/ecma426/#sec-linking-eval)
([displayURL](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.Source.html#displayurl)).

this patch builds on #38363, setting the correct introductionType value
in several more cases.

Testing: will undergo many automated tests in #38334
Fixes: part of #36027

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
shuppy 2025-08-09 13:05:54 +08:00 committed by GitHub
parent ff4971012f
commit 6471587fb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 77 additions and 15 deletions

View file

@ -836,6 +836,7 @@ impl ModuleTree {
}
#[allow(unsafe_code)]
// FIXME: spec links in this function are all broken, so its unclear what this algorithm does
/// <https://html.spec.whatwg.org/multipage/#fetch-the-descendants-of-a-module-script>
fn fetch_module_descendants(
&self,
@ -929,6 +930,8 @@ impl ModuleTree {
Some(parent_identity.clone()),
false,
None,
// TODO: is this correct?
Some(IntroductionType::IMPORTED_MODULE),
can_gc,
);
}
@ -1200,6 +1203,8 @@ struct ModuleContext {
status: Result<(), NetworkError>,
/// Timing object for this resource
resource_timing: ResourceFetchTiming,
/// `introductionType` value to set in the `CompileOptionsWrapper`.
introduction_type: Option<&'static CStr>,
}
impl FetchResponseListener for ModuleContext {
@ -1336,7 +1341,7 @@ impl FetchResponseListener for ModuleContext {
compiled_module.handle_mut(),
false,
CanGc::note(),
None,
self.introduction_type,
);
match compiled_module_result {
@ -1570,6 +1575,7 @@ fn fetch_an_import_module_script_graph(
None,
true,
Some(dynamic_module),
Some(IntroductionType::IMPORTED_MODULE),
can_gc,
);
Ok(())
@ -1675,6 +1681,7 @@ pub(crate) fn fetch_external_module_script(
None,
true,
None,
Some(IntroductionType::SRC_SCRIPT),
can_gc,
)
}
@ -1738,6 +1745,7 @@ fn fetch_single_module_script(
parent_identity: Option<ModuleIdentity>,
top_level_module_fetch: bool,
dynamic_module: Option<RootedTraceableBox<DynamicModule>>,
introduction_type: Option<&'static CStr>,
can_gc: CanGc,
) {
{
@ -1857,6 +1865,7 @@ fn fetch_single_module_script(
options,
status: Ok(()),
resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource),
introduction_type,
}));
let network_listener = NetworkListener {