Skip to content

Instantly share code, notes, and snippets.

@jdm
Created September 11, 2015 19:19
Show Gist options
  • Select an option

  • Save jdm/2cf61ebbe2e584eba676 to your computer and use it in GitHub Desktop.

Select an option

Save jdm/2cf61ebbe2e584eba676 to your computer and use it in GitHub Desktop.
interdiff
diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -46,16 +46,17 @@ NS_IMPL_ISUPPORTS(FetchDriver,
FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
nsILoadGroup* aLoadGroup)
: mPrincipal(aPrincipal)
, mLoadGroup(aLoadGroup)
, mRequest(aRequest)
, mFetchRecursionCount(0)
, mCORSFlagEverSet(false)
+ , mRequestFailed(false)
, mResponseAvailableCalled(false)
{
}
FetchDriver::~FetchDriver()
{
// We assert this since even on failures, we should call
// FailWithNetworkError().
@@ -637,18 +638,20 @@ FetchDriver::HttpFetch(bool aCORSFlag, b
// Step 4 onwards of "HTTP Fetch" is handled internally by Necko.
return NS_OK;
}
nsresult
FetchDriver::ContinueHttpFetchAfterNetworkFetch()
{
workers::AssertIsOnMainThread();
- MOZ_ASSERT(mResponse);
- MOZ_ASSERT(!mResponse->IsError());
+ if (!mRequestFailed) {
+ MOZ_ASSERT(mResponse);
+ MOZ_ASSERT(!mResponse->IsError());
+ }
return SucceedWithResponse();
}
already_AddRefed<InternalResponse>
FetchDriver::BeginAndGetFilteredResponse(InternalResponse* aResponse, nsIURI* aFinalURI)
{
MOZ_ASSERT(aResponse);
@@ -760,16 +763,17 @@ FetchDriver::OnStartRequest(nsIRequest*
// Note, this can be called multiple times if we are doing an opaqueredirect.
// In that case we will get a simulated OnStartRequest() and then the real
// channel will call in with an errored OnStartRequest().
nsresult rv;
aRequest->GetStatus(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
+ mRequestFailed = true;
FailWithNetworkError();
return rv;
}
// We should only get to the following code once.
MOZ_ASSERT(!mPipeOutputStream);
MOZ_ASSERT(mObserver);
diff --git a/dom/fetch/FetchDriver.h b/dom/fetch/FetchDriver.h
--- a/dom/fetch/FetchDriver.h
+++ b/dom/fetch/FetchDriver.h
@@ -86,16 +86,17 @@ private:
nsRefPtr<FetchDriverObserver> mObserver;
nsCOMPtr<nsIInterfaceRequestor> mNotificationCallbacks;
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
nsCOMPtr<nsIChannel> mOldRedirectChannel;
nsCOMPtr<nsIChannel> mNewRedirectChannel;
nsCOMPtr<nsIDocument> mDocument;
uint32_t mFetchRecursionCount;
bool mCORSFlagEverSet;
+ bool mRequestFailed;
DebugOnly<bool> mResponseAvailableCalled;
FetchDriver() = delete;
FetchDriver(const FetchDriver&) = delete;
FetchDriver& operator=(const FetchDriver&) = delete;
~FetchDriver();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment