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

@ -154,7 +154,8 @@ use crate::navigation::{InProgressLoad, NavigationListener};
use crate::realms::enter_realm;
use crate::script_module::ScriptFetchOptions;
use crate::script_runtime::{
CanGc, JSContext, JSContextHelper, Runtime, ScriptThreadEventCategory, ThreadSafeJSContext,
CanGc, IntroductionType, JSContext, JSContextHelper, Runtime, ScriptThreadEventCategory,
ThreadSafeJSContext,
};
use crate::task_queue::TaskQueue;
use crate::task_source::{SendableTaskSource, TaskSourceName};
@ -3739,6 +3740,7 @@ impl ScriptThread {
ScriptFetchOptions::default_classic_script(global_scope),
global_scope.api_base_url(),
can_gc,
Some(IntroductionType::JAVASCRIPT_URL),
);
load_data.js_eval_result = if jsval.get().is_string() {
@ -4093,6 +4095,7 @@ impl ScriptThread {
ScriptFetchOptions::default_classic_script(global_scope),
global_scope.api_base_url(),
can_gc,
None, // No known `introductionType` for JS code from embedder
);
let result = match jsval_to_webdriver(
context,