servo/components/script_bindings
shuppy 52f53f61e1
script: Add support for creating globals in isolated compartments (#38236)
to use the [SpiderMonkey Debugger
API](https://firefox-source-docs.mozilla.org/js/Debugger/), we need to
call it from an internal debugger script that we will supply. this
script must run in the same runtime as the debuggee(s), but in a
separate
[compartment](https://udn.realityripple.com/docs/Mozilla/Projects/SpiderMonkey/Compartments)
([more
details](https://hacks.mozilla.org/2020/03/future-proofing-firefoxs-javascript-debugger-implementation/)).

when creating two globals in the same runtime, Servo will generally try
to reuse an existing compartment for the second global, and there are
other places in script where we rely on this reuse. but for the debugger
script, we can’t do this.

this patch adds a `use_system_compartment` flag to global object
descriptors, which isolates the global in its own compartment in both
possible directions:
- it forces the global to create a new compartment, preventing the reuse
of any debuggee’s compartment
- it fails the check in select_compartment(), preventing future
debuggees from reusing the global’s compartment

Testing: manually tested working in devtools debugger patch (#37667),
where it will undergo automated tests

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
2025-07-23 11:34:37 +00:00
..
codegen script: Add support for creating globals in isolated compartments (#38236) 2025-07-23 11:34:37 +00:00
webidls script: Implement DocumentOrShadowDOM.adoptedStylesheet with FrozenArray (#38163) 2025-07-23 08:16:01 +00:00
build.rs Mergeruff.toml into pyproject.toml (#37741) 2025-07-04 12:21:48 +00:00
callback.rs Implement "Create a Trusted Type" algorithm (#36454) 2025-04-13 03:55:23 +00:00
Cargo.toml script: Pass more information to the MouseEvent constructor (#37672) 2025-06-25 12:29:27 +00:00
constant.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
constructor.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
conversions.rs script: Impl safe from_jsval wrapper (#38149) 2025-07-17 19:32:36 +00:00
error.rs script: Add a Constraint DOMException for IndexedDB (#37605) 2025-07-12 10:08:40 +00:00
finalize.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
guard.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
import.rs Make ImageData more spec compliant (#37620) 2025-06-25 16:48:58 +00:00
inheritance.rs More miscellaneous script splitting changes (#36220) 2025-03-30 11:06:30 +00:00
interface.rs script: Add support for creating globals in isolated compartments (#38236) 2025-07-23 11:34:37 +00:00
interfaces.rs codegen: use FromJSValConvertible trait for Promise (#36966) 2025-05-12 11:05:46 +00:00
iterable.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
lib.rs Make the crown disabled warning clearer and less scary (#37535) 2025-06-19 12:44:26 +00:00
like.rs Move more bindings types to script_bindings (#35620) 2025-02-23 14:25:46 +00:00
lock.rs Miscellaneous script splitting preparation changes (#36216) 2025-03-29 08:11:27 +00:00
mem.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
namespace.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
num.rs Miscellaneous script splitting preparation changes (#36216) 2025-03-29 08:11:27 +00:00
principals.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
proxyhandler.rs Fix crash when setting custom property on Location (#36494) 2025-04-16 06:52:48 +00:00
realms.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
record.rs Implement URLPattern::{text, exec} (#37044) 2025-05-24 11:12:11 +00:00
reflector.rs script: Return global objects for DOM objects in the relevant realm (#37120) 2025-05-25 03:21:05 +00:00
root.rs Don't allocate in Dom::trace even when debug assertions are enabled (#37487) 2025-06-16 17:32:33 +00:00
script_runtime.rs Move more bindings code to script_bindings (#35578) 2025-02-22 04:46:56 +00:00
settings_stack.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
str.rs Implement static Response.json (#36589) 2025-04-25 08:49:21 +00:00
trace.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
utils.rs Eagerly define interfaces on non-Window globals (#36604) 2025-04-21 03:32:21 +00:00
weakref.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00