mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1218621 - Keep the service worker alive while the promise passed to FetchEvent.respondWith() settles; r=catalinb
This commit is contained in:
parent
889f2d5617
commit
6dc5dafa7c
@ -59,9 +59,9 @@ CancelChannelRunnable::Run()
|
||||
}
|
||||
|
||||
FetchEvent::FetchEvent(EventTarget* aOwner)
|
||||
: ExtendableEvent(aOwner)
|
||||
, mIsReload(false)
|
||||
, mWaitToRespond(false)
|
||||
: ExtendableEvent(aOwner)
|
||||
, mIsReload(false)
|
||||
, mWaitToRespond(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -436,15 +436,6 @@ FetchEvent::RespondWith(Promise& aArg, ErrorResult& aRv)
|
||||
return;
|
||||
}
|
||||
|
||||
// 4.5.3.2 If the respond-with entered flag is set, then:
|
||||
// Throw an "InvalidStateError" exception.
|
||||
// Here we use |mPromise != nullptr| as respond-with enter flag
|
||||
if (mPromise) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
mPromise = &aArg;
|
||||
|
||||
RefPtr<InternalRequest> ir = mRequest->GetInternalRequest();
|
||||
StopImmediatePropagation();
|
||||
mWaitToRespond = true;
|
||||
@ -452,6 +443,8 @@ FetchEvent::RespondWith(Promise& aArg, ErrorResult& aRv)
|
||||
new RespondWithHandler(mChannel, mRequest->Mode(), ir->IsClientRequest(),
|
||||
ir->IsNavigationRequest(), mScriptSpec);
|
||||
aArg.AppendNativeHandler(handler);
|
||||
|
||||
WaitUntil(aArg, aRv);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(FetchEvent, ExtendableEvent)
|
||||
@ -460,8 +453,7 @@ NS_IMPL_RELEASE_INHERITED(FetchEvent, ExtendableEvent)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FetchEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(ExtendableEvent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(FetchEvent, ExtendableEvent,
|
||||
mRequest, mPromise)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(FetchEvent, ExtendableEvent, mRequest)
|
||||
|
||||
ExtendableEvent::ExtendableEvent(EventTarget* aOwner)
|
||||
: Event(aOwner, nullptr, nullptr)
|
||||
|
@ -103,7 +103,6 @@ class FetchEvent final : public ExtendableEvent
|
||||
nsMainThreadPtrHandle<nsIInterceptedChannel> mChannel;
|
||||
RefPtr<Request> mRequest;
|
||||
nsCString mScriptSpec;
|
||||
RefPtr<Promise> mPromise;
|
||||
bool mIsReload;
|
||||
bool mWaitToRespond;
|
||||
protected:
|
||||
@ -150,13 +149,6 @@ public:
|
||||
void
|
||||
RespondWith(Promise& aArg, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
GetPromise() const
|
||||
{
|
||||
RefPtr<Promise> p = mPromise;
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
ForwardTo(const nsAString& aUrl);
|
||||
|
||||
|
@ -1175,11 +1175,11 @@ private:
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(runnable)));
|
||||
}
|
||||
|
||||
RefPtr<Promise> respondWithPromise = event->GetPromise();
|
||||
if (respondWithPromise) {
|
||||
RefPtr<Promise> waitUntilPromise = event->GetPromise();
|
||||
if (waitUntilPromise) {
|
||||
RefPtr<KeepAliveHandler> keepAliveHandler =
|
||||
new KeepAliveHandler(mKeepAliveToken);
|
||||
respondWithPromise->AppendNativeHandler(keepAliveHandler);
|
||||
waitUntilPromise->AppendNativeHandler(keepAliveHandler);
|
||||
}
|
||||
|
||||
// 9.8.22 If request is a non-subresource request, then: Invoke Soft Update algorithm
|
||||
|
Loading…
Reference in New Issue
Block a user