CanGc fixes in messageport.rs & workerglobalscope.rs (#34003)

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-10-25 19:23:53 +05:30 committed by GitHub
parent 7ad8822d94
commit fd6c100489
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 6 deletions

View file

@ -347,6 +347,7 @@ DOMInterfaces = {
'MessagePort': {
'weakReferenceable': True,
'canGc': ['GetOnmessage'],
},
'NavigationPreloadManager': {

View file

@ -464,7 +464,7 @@ impl DedicatedWorkerGlobalScope {
{
let _ar = AutoWorkerReset::new(&global, worker.clone());
let _ac = enter_realm(scope);
scope.execute_script(DOMString::from(source));
scope.execute_script(DOMString::from(source), CanGc::note());
}
let reporter_name = format!("dedicated-worker-reporter-{}", random::<u64>());

View file

@ -322,12 +322,12 @@ impl MessagePortMethods for MessagePort {
}
/// <https://html.spec.whatwg.org/multipage/#handler-messageport-onmessage>
fn GetOnmessage(&self) -> Option<Rc<EventHandlerNonNull>> {
fn GetOnmessage(&self, can_gc: CanGc) -> Option<Rc<EventHandlerNonNull>> {
if self.detached.get() {
return None;
}
let eventtarget = self.upcast::<EventTarget>();
eventtarget.get_event_handler_common("message", CanGc::note())
eventtarget.get_event_handler_common("message", can_gc)
}
/// <https://html.spec.whatwg.org/multipage/#handler-messageport-onmessage>

View file

@ -384,7 +384,7 @@ impl ServiceWorkerGlobalScope {
{
// TODO: use AutoWorkerReset as in dedicated worker?
let _ac = enter_realm(scope);
scope.execute_script(DOMString::from(source));
scope.execute_script(DOMString::from(source), CanGc::note());
}
global.dispatch_activate(CanGc::note());

View file

@ -447,7 +447,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
impl WorkerGlobalScope {
#[allow(unsafe_code)]
pub fn execute_script(&self, source: DOMString) {
pub fn execute_script(&self, source: DOMString, can_gc: CanGc) {
let _aes = AutoEntryScript::new(self.upcast());
let cx = self.runtime.borrow().as_ref().unwrap().cx();
rooted!(in(cx) let mut rval = UndefinedValue());
@ -468,7 +468,7 @@ impl WorkerGlobalScope {
println!("evaluate_script failed");
unsafe {
let ar = enter_realm(self);
report_pending_exception(cx, true, InRealm::Entered(&ar), CanGc::note());
report_pending_exception(cx, true, InRealm::Entered(&ar), can_gc);
}
}
},