From b0f1420e24d582f09e23eaa4361e79507fbcac6f Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Fri, 11 Dec 2015 14:53:11 -0500 Subject: [PATCH] Bug 1226443 P6 Ignore update() called during top level service worker script evaluation. r=ehsan --- dom/workers/ServiceWorkerRegistration.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dom/workers/ServiceWorkerRegistration.cpp b/dom/workers/ServiceWorkerRegistration.cpp index 21bb739e309..e26215c38ef 100644 --- a/dom/workers/ServiceWorkerRegistration.cpp +++ b/dom/workers/ServiceWorkerRegistration.cpp @@ -1000,6 +1000,14 @@ ServiceWorkerRegistrationWorkerThread::Update(ErrorResult& aRv) return nullptr; } + // Avoid infinite update loops by ignoring update() calls during top + // level script evaluation. See: + // https://github.com/slightlyoff/ServiceWorker/issues/800 + if (worker->LoadScriptAsPartOfLoadingServiceWorkerScript()) { + promise->MaybeResolve(JS::UndefinedHandleValue); + return promise.forget(); + } + RefPtr proxy = PromiseWorkerProxy::Create(worker, promise); if (!proxy) { aRv.Throw(NS_ERROR_DOM_ABORT_ERR);