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

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

Issue 722583002: ServiceWorker: Abort register() and getRegistration() on non-http(s) page (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@fix_get_registration
Patch Set: Created 6 years, 1 month 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 980bf0088928e4460271c32123ac59685c0a641c..5c7d8fb6b8dde18c1c539c164a73f5d88e4487e0 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -122,6 +122,11 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS
return promise;
}
+ if (!executionContext->url().protocolIsInHTTPFamily()) {
+ resolver->reject(DOMException::create(SecurityError, "The URL protocol of the current origin is not supported: " + executionContext->url().protocol()));
+ return promise;
+ }
+
KURL patternURL = executionContext->completeURL(options.scope());
patternURL.removeFragmentIdentifier();
if (!documentOrigin->canRequest(patternURL)) {
@@ -180,6 +185,11 @@ ScriptPromise ServiceWorkerContainer::getRegistration(ScriptState* scriptState,
return promise;
}
+ if (!executionContext->url().protocolIsInHTTPFamily()) {
+ resolver->reject(DOMException::create(SecurityError, "The URL protocol of the current origin is not supported: " + executionContext->url().protocol()));
+ return promise;
+ }
+
KURL completedURL = executionContext->completeURL(documentURL);
completedURL.removeFragmentIdentifier();
if (!documentOrigin->canRequest(completedURL)) {

Powered by Google App Engine
This is Rietveld 408576698