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

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: fix wrong comment 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
« no previous file with comments | « LayoutTests/fast/serviceworker/access-container-on-local-file.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index 980bf0088928e4460271c32123ac59685c0a641c..25036c9027024c5913f56ee033579559cabd2686 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -122,6 +122,12 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS
return promise;
}
+ KURL pageURL = KURL(KURL(), documentOrigin->toString());
+ if (!pageURL.protocolIsInHTTPFamily()) {
+ resolver->reject(DOMException::create(SecurityError, "The URL protocol of the current origin is not supported: " + pageURL.protocol()));
+ return promise;
+ }
+
KURL patternURL = executionContext->completeURL(options.scope());
patternURL.removeFragmentIdentifier();
if (!documentOrigin->canRequest(patternURL)) {
@@ -180,6 +186,12 @@ ScriptPromise ServiceWorkerContainer::getRegistration(ScriptState* scriptState,
return promise;
}
+ KURL pageURL = KURL(KURL(), documentOrigin->toString());
+ if (!pageURL.protocolIsInHTTPFamily()) {
+ resolver->reject(DOMException::create(SecurityError, "The URL protocol of the current origin is not supported: " + pageURL.protocol()));
+ return promise;
+ }
+
KURL completedURL = executionContext->completeURL(documentURL);
completedURL.removeFragmentIdentifier();
if (!documentOrigin->canRequest(completedURL)) {
« no previous file with comments | « LayoutTests/fast/serviceworker/access-container-on-local-file.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698