Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1703)

Unified Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 1260003003: Move Service Worker %2f validation logic from browser into Blink (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add prefix error label before failure message. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index cbb117f1608a182fa1b5eb6f6cb283d14054f27d..715f6532bdee5761e74e2f040bf28543a8607acc 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -35,6 +35,7 @@
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/SerializedScriptValue.h"
#include "bindings/core/v8/SerializedScriptValueFactory.h"
+#include "bindings/core/v8/V8ThrowException.h"
#include "core/dom/DOMException.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
@@ -246,6 +247,12 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS
return promise;
}
+ WebString webErrorMessage;
+ if (!m_provider->validateScopeAndScriptURL(patternURL, scriptURL, &webErrorMessage)) {
falken 2015/08/05 06:54:23 Ah it's kind of weird that validateScopeAndScript
nhiroki 2015/08/05 07:15:09 Ah, good point. Moving validateSASURL into Platfor
nhiroki 2015/08/05 07:31:58 I had an offline chat w/ jeremy and falken. We dec
+ resolver->reject(V8ThrowException::createTypeError(scriptState->isolate(), WebString::fromUTF8("Failed to register a ServiceWorker: " + webErrorMessage.utf8())));
+ return promise;
+ }
+
m_provider->registerServiceWorker(patternURL, scriptURL, new RegistrationCallback(resolver));
return promise;
« no previous file with comments | « LayoutTests/http/tests/serviceworker/registration.html ('k') | Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698