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

@ -360,17 +360,21 @@ impl ServiceWorkerGlobalScope {
.referrer_policy(referrer_policy)
.origin(origin);
let (_url, source) =
match load_whole_resource(request, &resource_threads_sender, global.upcast()) {
Err(_) => {
println!("error loading script {}", serialized_worker_url);
scope.clear_js_runtime();
return;
},
Ok((metadata, bytes)) => {
(metadata.final_url, String::from_utf8(bytes).unwrap())
},
};
let (_url, source) = match load_whole_resource(
request,
&resource_threads_sender,
global.upcast(),
CanGc::note(),
) {
Err(_) => {
println!("error loading script {}", serialized_worker_url);
scope.clear_js_runtime();
return;
},
Ok((metadata, bytes)) => {
(metadata.final_url, String::from_utf8(bytes).unwrap())
},
};
unsafe {
// Handle interrupt requests
@ -465,7 +469,8 @@ impl ServiceWorkerGlobalScope {
// TODO XXXcreativcoder This will eventually use a FetchEvent interface to fire event
// when we have the Request and Response dom api's implemented
// https://w3c.github.io/ServiceWorker/#fetchevent-interface
self.upcast::<EventTarget>().fire_event(atom!("fetch"));
self.upcast::<EventTarget>()
.fire_event(atom!("fetch"), can_gc);
let _ = mediator.response_chan.send(None);
},
WakeUp => {},