mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add new Window globals as debuggees
Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
parent
4d7a514923
commit
bae25bb596
3 changed files with 49 additions and 0 deletions
|
@ -16,8 +16,10 @@ use js::rust::Runtime;
|
||||||
use js::rust::wrappers::JS_DefineDebuggerObject;
|
use js::rust::wrappers::JS_DefineDebuggerObject;
|
||||||
use net_traits::ResourceThreads;
|
use net_traits::ResourceThreads;
|
||||||
use profile_traits::{mem, time};
|
use profile_traits::{mem, time};
|
||||||
|
use script_bindings::conversions::SafeToJSValConvertible;
|
||||||
use script_bindings::realms::InRealm;
|
use script_bindings::realms::InRealm;
|
||||||
use script_bindings::reflector::DomObject;
|
use script_bindings::reflector::DomObject;
|
||||||
|
use script_bindings::utils::set_dictionary_property;
|
||||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DebuggerGlobalScopeBinding;
|
use crate::dom::bindings::codegen::Bindings::DebuggerGlobalScopeBinding;
|
||||||
|
@ -116,4 +118,31 @@ impl DebuggerGlobalScope {
|
||||||
warn!("Failed to execute debugger request");
|
warn!("Failed to execute debugger request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
pub(crate) fn execute_with_global(&self, can_gc: CanGc, global: &GlobalScope) {
|
||||||
|
let cx = Self::get_cx();
|
||||||
|
rooted!(in(*cx) let mut property_value = UndefinedValue());
|
||||||
|
|
||||||
|
let _realm = enter_realm(self);
|
||||||
|
// Convert the debuggee global’s reflector to a Value, wrapping it from its originating realm (debuggee realm)
|
||||||
|
// into the active realm (debugger realm) so that it can be passed across compartments.
|
||||||
|
global
|
||||||
|
.reflector()
|
||||||
|
.safe_to_jsval(cx, property_value.handle_mut());
|
||||||
|
|
||||||
|
// TODO: what invariants do we need to uphold for the unsafe call?
|
||||||
|
if let Err(()) = unsafe {
|
||||||
|
set_dictionary_property(
|
||||||
|
*cx,
|
||||||
|
self.global_scope.reflector().get_jsobject(),
|
||||||
|
"debuggee",
|
||||||
|
property_value.handle(),
|
||||||
|
)
|
||||||
|
} {
|
||||||
|
warn!("Failed to set debuggee");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.execute(can_gc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3430,6 +3430,8 @@ impl ScriptThread {
|
||||||
incomplete.load_data.inherited_secure_context,
|
incomplete.load_data.inherited_secure_context,
|
||||||
incomplete.theme,
|
incomplete.theme,
|
||||||
);
|
);
|
||||||
|
self.debugger_global
|
||||||
|
.execute_with_global(can_gc, window.upcast());
|
||||||
|
|
||||||
let _realm = enter_realm(&*window);
|
let _realm = enter_realm(&*window);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
if (!("dbg" in this)) {
|
if (!("dbg" in this)) {
|
||||||
dbg = new Debugger;
|
dbg = new Debugger;
|
||||||
|
|
||||||
|
dbg.onNewGlobalObject = function(global) {
|
||||||
|
console.log("[debugger] onNewGlobalObject");
|
||||||
|
console.log(this, global);
|
||||||
|
};
|
||||||
|
|
||||||
|
dbg.onNewScript = function(script, global) {
|
||||||
|
console.log("[debugger] onNewScript");
|
||||||
|
console.log(this, script, global);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("[debugger] Executing");
|
||||||
|
|
||||||
|
if ("debuggee" in this) {
|
||||||
|
console.log("[debugger] Adding debuggee");
|
||||||
|
dbg.addDebuggee(debuggee);
|
||||||
|
console.log("[debugger] getDebuggees().length =", dbg.getDebuggees().length);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue