Skip to content

Conversation

@delan
Copy link
Member

@delan delan commented Jul 30, 2025

to use the SpiderMonkey Debugger API as the single source of truth about scripts and their sources for devtools purposes (#38334), the debugger script needs to be able to distinguish inline scripts from other scripts, because inline scripts are a special case where the source contents need to come from the Servo parser.

the mechanism for this is Debugger.Script.prototype.introductionType, which is inlineScript for inline scripts or a variety of other values for other kinds of scripts, but only the embedder can provide this information.

this patch bumps mozjs to servo/mozjs#603, which expands on CompileOptionsWrapper, making it a safe wrapper around CompileOptions. to construct one from safe code, use Runtime::new_compile_options(). then you can call set_introduction_type(&'static CStr) on the new instance. we also make Runtime::evaluate_script() take a CompileOptionsWrapper from the caller, instead of constructing one internally.

in this patch, we set the introductionType to c"inlineScript" when calling run_a_classic_script() and compile_module_script() for inline scripts, and leave it unset all other cases.

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

@delan delan marked this pull request as ready for review July 30, 2025 13:31
@delan delan requested a review from gterzian as a code owner July 30, 2025 13:31
@delan delan requested review from jdm and removed request for gterzian July 30, 2025 13:31
@delan delan force-pushed the introductionType branch 2 times, most recently from 6e19d22 to eacc365 Compare August 5, 2025 11:15
@delan delan requested a review from sagudev August 5, 2025 11:15
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
Signed-off-by: Delan Azabani <dazabani@igalia.com>
@delan delan force-pushed the introductionType branch from eacc365 to a8574fc Compare August 5, 2025 11:52
Copy link
Member

@sagudev sagudev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
@delan delan force-pushed the introductionType branch from afb32dc to 15069b2 Compare August 5, 2025 12:04
Signed-off-by: Delan Azabani <dazabani@igalia.com>
@delan delan added this pull request to the merge queue Aug 5, 2025
Merged via the queue into main with commit 3eddfea Aug 5, 2025
21 checks passed
@delan delan deleted the introductionType branch August 5, 2025 13:07
github-merge-queue bot pushed a commit that referenced this pull request Aug 9, 2025
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
(#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants