mirror of
https://github.com/servo/servo.git
synced 2025-07-29 02:00:23 +01:00
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>
This commit is contained in:
parent
d9f8fc505f
commit
52f53f61e1
3 changed files with 26 additions and 6 deletions
|
@ -3213,7 +3213,8 @@ create_global_object::<D>(
|
|||
raw.as_ptr() as *const libc::c_void,
|
||||
{TRACE_HOOK_NAME}::<D>,
|
||||
obj.handle_mut(),
|
||||
origin);
|
||||
origin,
|
||||
{"true" if self.descriptor.useSystemCompartment else "false"});
|
||||
assert!(!obj.is_null());
|
||||
|
||||
let root = raw.reflect_with(obj.get());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue