Bug 1119026 - Respect skip serviceworker flag. r=baku,bkelly

This commit is contained in:
Nikhil Marathe 2014-12-24 02:08:41 -08:00
parent 905b0da674
commit c5d867ffe6
3 changed files with 26 additions and 0 deletions

View File

@ -241,6 +241,11 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
} else {
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(worker);
if (worker->IsServiceWorker()) {
r->SetSkipServiceWorker();
}
nsRefPtr<MainThreadFetchRunnable> run = new MainThreadFetchRunnable(worker, p, r);
if (NS_FAILED(NS_DispatchToMainThread(run))) {
NS_WARNING("MainThreadFetchRunnable dispatch failed!");

View File

@ -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<nsIHttpChannelInternal> 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

View File

@ -179,6 +179,18 @@ public:
mReferrer.Assign(aReferrer);
}
bool
SkipServiceWorker() const
{
return mSkipServiceWorker;
}
void
SetSkipServiceWorker()
{
mSkipServiceWorker = true;
}
bool
IsSynchronous() const
{