mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
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:
parent
ff4971012f
commit
6471587fb4
11 changed files with 77 additions and 15 deletions
|
@ -1255,6 +1255,13 @@ pub(crate) use script_bindings::script_runtime::CanGc;
|
|||
// TODO: squish `scriptElement` <https://searchfox.org/mozilla-central/rev/202069c4c5113a1a9052d84fa4679d4c1b22113e/devtools/server/actors/source.js#199-201>
|
||||
pub(crate) struct IntroductionType;
|
||||
impl IntroductionType {
|
||||
/// `introductionType` for code evaluated by debugger.
|
||||
/// This includes code run via the devtools repl, even if the thread is not paused.
|
||||
pub const DEBUGGER_EVAL: &CStr = c"debugger eval";
|
||||
|
||||
/// `introductionType` for code loaded by worklet.
|
||||
pub const WORKLET: &CStr = c"Worklet";
|
||||
|
||||
/// `introductionType` for code belonging to `<script src="file.js">` elements.
|
||||
/// This includes `<script type="module" src="...">`.
|
||||
pub const SRC_SCRIPT: &CStr = c"srcScript";
|
||||
|
@ -1263,6 +1270,23 @@ impl IntroductionType {
|
|||
/// This includes `<script type="module" src="...">`.
|
||||
pub const INLINE_SCRIPT: &CStr = c"inlineScript";
|
||||
|
||||
/// `introductionType` for code belonging to scripts that *would* be `"inlineScript"` except that they were not
|
||||
/// part of the initial file itself.
|
||||
/// For example, scripts created via:
|
||||
/// - `document.write("<script>code;</script>")`
|
||||
/// - `var s = document.createElement("script"); s.text = "code";`
|
||||
pub const INJECTED_SCRIPT: &CStr = c"injectedScript";
|
||||
|
||||
/// `introductionType` for code that was loaded indirectly by being imported by another script
|
||||
/// using ESM static or dynamic imports.
|
||||
pub const IMPORTED_MODULE: &CStr = c"importedModule";
|
||||
|
||||
/// `introductionType` for code presented in `javascript:` URLs.
|
||||
pub const JAVASCRIPT_URL: &CStr = c"javascriptURL";
|
||||
|
||||
/// `introductionType` for code passed to `setTimeout`/`setInterval` as a string.
|
||||
pub const DOM_TIMER: &CStr = c"domTimer";
|
||||
|
||||
/// `introductionType` for web workers.
|
||||
/// <https://searchfox.org/mozilla-central/rev/202069c4c5113a1a9052d84fa4679d4c1b22113e/devtools/docs/user/debugger-api/debugger.source/index.rst#96>
|
||||
pub const WORKER: &CStr = c"Worker";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue