From ebb4d897937e5673923fe2683bfa9adc870f2068 Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Wed, 24 Dec 2014 02:08:41 -0800 Subject: [PATCH] Bug 1119026 - Respect skip serviceworker flag. r=baku,bkelly --HG-- extra : rebase_source : 569b51af36fd8c19b59c5d01b88dadddc84d4153 --- dom/fetch/Fetch.cpp | 5 +++++ dom/fetch/FetchDriver.cpp | 9 +++++++++ dom/fetch/InternalRequest.h | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp index d7a96fd35ae4..1a875a2af185 100644 --- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -241,6 +241,11 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput, } else { WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); + + if (worker->IsServiceWorker()) { + r->SetSkipServiceWorker(); + } + nsRefPtr run = new MainThreadFetchRunnable(worker, p, r); if (NS_FAILED(NS_DispatchToMainThread(run))) { NS_WARNING("MainThreadFetchRunnable dispatch failed!"); diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index f8109db0f454..31462cf3b334 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -8,6 +8,7 @@ #include "nsIInputStream.h" #include "nsIOutputStream.h" #include "nsIHttpChannel.h" +#include "nsIHttpChannelInternal.h" #include "nsIHttpHeaderVisitor.h" #include "nsIScriptSecurityManager.h" #include "nsIThreadRetargetableRequest.h" @@ -450,6 +451,14 @@ FetchDriver::HttpFetch(bool aCORSFlag, bool aCORSPreflightFlag, bool aAuthentica } } + // Set skip serviceworker flag. + // While the spec also gates on the client being a ServiceWorker, we can't + // infer that here. Instead we rely on callers to set the flag correctly. + if (mRequest->SkipServiceWorker()) { + nsCOMPtr internalChan = do_QueryInterface(httpChan); + internalChan->ForceNoIntercept(); + } + // Set up a CORS proxy that will handle the various requirements of the CORS // protocol. It handles the preflight cache and CORS response headers. // If the request is allowed, it will start our original request diff --git a/dom/fetch/InternalRequest.h b/dom/fetch/InternalRequest.h index 2fa4324d256e..6e19fc1d9d2e 100644 --- a/dom/fetch/InternalRequest.h +++ b/dom/fetch/InternalRequest.h @@ -179,6 +179,18 @@ public: mReferrer.Assign(aReferrer); } + bool + SkipServiceWorker() const + { + return mSkipServiceWorker; + } + + void + SetSkipServiceWorker() + { + mSkipServiceWorker = true; + } + bool IsSynchronous() const {