CanGc fixes from EventTarget::fire_event (#33985)

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-10-24 04:18:19 +05:30 committed by GitHub
parent bb4932026c
commit ea875f0a51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 155 additions and 115 deletions

View file

@ -27,7 +27,7 @@ use crate::dom::bindings::structuredclone;
use crate::dom::bindings::trace::RootedTraceableBox;
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::JSContext;
use crate::script_runtime::{CanGc, JSContext};
use crate::task::TaskOnce;
pub type TrustedServiceWorkerAddress = Trusted<ServiceWorker>;
@ -74,15 +74,15 @@ impl ServiceWorker {
)
}
pub fn dispatch_simple_error(address: TrustedServiceWorkerAddress) {
pub fn dispatch_simple_error(address: TrustedServiceWorkerAddress, can_gc: CanGc) {
let service_worker = address.root();
service_worker.upcast().fire_event(atom!("error"));
service_worker.upcast().fire_event(atom!("error"), can_gc);
}
pub fn set_transition_state(&self, state: ServiceWorkerState) {
pub fn set_transition_state(&self, state: ServiceWorkerState, can_gc: CanGc) {
self.state.set(state);
self.upcast::<EventTarget>()
.fire_event(atom!("statechange"));
.fire_event(atom!("statechange"), can_gc);
}
pub fn get_script_url(&self) -> ServoUrl {
@ -167,6 +167,6 @@ impl ServiceWorkerMethods for ServiceWorker {
impl TaskOnce for SimpleWorkerErrorHandler<ServiceWorker> {
#[allow(crown::unrooted_must_root)]
fn run_once(self) {
ServiceWorker::dispatch_simple_error(self.addr);
ServiceWorker::dispatch_simple_error(self.addr, CanGc::note());
}
}