@@ -1754,7 +1754,14 @@ bool RequestOrResponse::body_reader_then_handler(JSContext *cx, JS::HandleObject
17541754 // `responseDone`.
17551755 if (Response::is_instance (body_owner)) {
17561756 ENGINE->decr_event_loop_interest ();
1757- FetchEvent::set_state (FetchEvent::instance (), FetchEvent::State::responseDone);
1757+ JS::RootedValue fetch_event_val (
1758+ cx, JS::GetReservedSlot (body_owner, static_cast <uint32_t >(Response::Slots::FetchEvent)));
1759+ if (!fetch_event_val.isObject ()) {
1760+ JS_ReportErrorASCII (cx, " Response does not have an associated FetchEvent" );
1761+ return false ;
1762+ }
1763+ JS::RootedObject fetch_event (cx, &fetch_event_val.toObject ());
1764+ FetchEvent::set_state (fetch_event, FetchEvent::State::responseDone);
17581765 }
17591766
17601767 auto res = body.close ();
@@ -1844,7 +1851,14 @@ bool RequestOrResponse::body_reader_catch_handler(JSContext *cx, JS::HandleObjec
18441851 // a response at all failed.)
18451852 if (Response::is_instance (body_owner)) {
18461853 ENGINE->decr_event_loop_interest ();
1847- FetchEvent::set_state (FetchEvent::instance (), FetchEvent::State::responseDone);
1854+ JS::RootedValue fetch_event_val (
1855+ cx, JS::GetReservedSlot (body_owner, static_cast <uint32_t >(Response::Slots::FetchEvent)));
1856+ if (!fetch_event_val.isObject ()) {
1857+ JS_ReportErrorASCII (cx, " Response does not have an associated FetchEvent" );
1858+ return false ;
1859+ }
1860+ JS::RootedObject fetch_event (cx, &fetch_event_val.toObject ());
1861+ FetchEvent::set_state (fetch_event, FetchEvent::State::responseDone);
18481862 }
18491863 return true ;
18501864}
0 commit comments