Commit 1731f1fc authored by Kagami Sascha Rosylight's avatar Kagami Sascha Rosylight
Browse files

Bug 1907428 - Return when mPromise is null r=sunil

We should probably remove FetchObserver at this point, btw.

Differential Revision: https://phabricator.services.mozilla.com/D221516
parent 22e4949a
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -89,8 +89,13 @@ mozilla::ipc::IPCResult FetchChild::RecvOnResponseAvailableInternal(
    if (mFetchObserver) {
      mFetchObserver->SetState(FetchState::Complete);
    }

    // mFetchObserver->SetState runs JS and a blocking JS function can run
    // queued runnables, including ActorDestroy that nullifies mPromise.
    if (!mPromise) {
      return IPC_OK();
    }
    nsCOMPtr<nsIGlobalObject> global;
    // global = mWorkerRef->Private()->GlobalScope();
    global = mPromise->GetGlobalObject();
    RefPtr<Response> response =
        new Response(global, internalResponse.clonePtr(), mSignalImpl);
@@ -106,6 +111,12 @@ mozilla::ipc::IPCResult FetchChild::RecvOnResponseAvailableInternal(
  if (mFetchObserver) {
    mFetchObserver->SetState(FetchState::Errored);
  }

  // mFetchObserver->SetState runs JS and a blocking JS function can run queued
  // runnables, including ActorDestroy that nullifies mPromise.
  if (!mPromise) {
    return IPC_OK();
  }
  mPromise->MaybeRejectWithTypeError<MSG_FETCH_FAILED>();
  return IPC_OK();
}
@@ -128,6 +139,12 @@ mozilla::ipc::IPCResult FetchChild::RecvOnResponseEnd(ResponseEndArgs&& aArgs) {
    if (mFetchObserver) {
      mFetchObserver->SetState(FetchState::Errored);
    }

    // mFetchObserver->SetState runs JS and a blocking JS function can run
    // queued runnables, including ActorDestroy that nullifies mPromise.
    if (!mPromise) {
      return IPC_OK();
    }
    mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
  }

+18 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<meta charset="utf-8">
<script>
const onstatechange = () => {
  const xhr = new XMLHttpRequest("󠟨.")
  xhr.open("POST", "1", false)
  xhr.send()
}
const observe = (ev) => {
  ev.addEventListener("statechange", onstatechange, { })
}
document.addEventListener("DOMContentLoaded", async () => {
  await self.fetch(".", {
    keepalive: true,
    observe,
  })
})
</script>
+1 −0
Original line number Diff line number Diff line
load 1577196.html
load 1664514.html
pref(dom.fetchKeepalive.enabled,true) pref(dom.fetchObserver.enabled,true) HTTP load 1907428.html