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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // FIXME: This should use the container's execution context, not 115 // FIXME: This should use the container's execution context, not
116 // the callers. 116 // the callers.
117 ExecutionContext* executionContext = scriptState->executionContext(); 117 ExecutionContext* executionContext = scriptState->executionContext();
118 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 118 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
119 String errorMessage; 119 String errorMessage;
120 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { 120 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) {
121 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 121 resolver->reject(DOMException::create(NotSupportedError, errorMessage));
122 return promise; 122 return promise;
123 } 123 }
124 124
125 KURL pageURL = KURL(KURL(), documentOrigin->toString());
126 if (!pageURL.protocolIsInHTTPFamily()) {
127 resolver->reject(DOMException::create(SecurityError, "The URL protocol o f the current origin is not supported: " + pageURL.protocol()));
128 return promise;
129 }
130
125 KURL patternURL = executionContext->completeURL(options.scope()); 131 KURL patternURL = executionContext->completeURL(options.scope());
126 patternURL.removeFragmentIdentifier(); 132 patternURL.removeFragmentIdentifier();
127 if (!documentOrigin->canRequest(patternURL)) { 133 if (!documentOrigin->canRequest(patternURL)) {
128 resolver->reject(DOMException::create(SecurityError, "The scope must mat ch the current origin.")); 134 resolver->reject(DOMException::create(SecurityError, "The scope must mat ch the current origin."));
129 return promise; 135 return promise;
130 } 136 }
131 137
132 KURL scriptURL = executionContext->completeURL(url); 138 KURL scriptURL = executionContext->completeURL(url);
133 scriptURL.removeFragmentIdentifier(); 139 scriptURL.removeFragmentIdentifier();
134 if (!documentOrigin->canRequest(scriptURL)) { 140 if (!documentOrigin->canRequest(scriptURL)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // FIXME: This should use the container's execution context, not 179 // FIXME: This should use the container's execution context, not
174 // the callers. 180 // the callers.
175 ExecutionContext* executionContext = scriptState->executionContext(); 181 ExecutionContext* executionContext = scriptState->executionContext();
176 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 182 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
177 String errorMessage; 183 String errorMessage;
178 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { 184 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) {
179 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 185 resolver->reject(DOMException::create(NotSupportedError, errorMessage));
180 return promise; 186 return promise;
181 } 187 }
182 188
189 KURL pageURL = KURL(KURL(), documentOrigin->toString());
190 if (!pageURL.protocolIsInHTTPFamily()) {
191 resolver->reject(DOMException::create(SecurityError, "The URL protocol o f the current origin is not supported: " + pageURL.protocol()));
192 return promise;
193 }
194
183 KURL completedURL = executionContext->completeURL(documentURL); 195 KURL completedURL = executionContext->completeURL(documentURL);
184 completedURL.removeFragmentIdentifier(); 196 completedURL.removeFragmentIdentifier();
185 if (!documentOrigin->canRequest(completedURL)) { 197 if (!documentOrigin->canRequest(completedURL)) {
186 resolver->reject(DOMException::create(SecurityError, "The documentURL mu st match the current origin.")); 198 resolver->reject(DOMException::create(SecurityError, "The documentURL mu st match the current origin."));
187 return promise; 199 return promise;
188 } 200 }
189 m_provider->getRegistration(completedURL, new GetRegistrationCallback(resolv er)); 201 m_provider->getRegistration(completedURL, new GetRegistrationCallback(resolv er));
190 202
191 return promise; 203 return promise;
192 } 204 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 m_ready = createReadyProperty(); 281 m_ready = createReadyProperty();
270 282
271 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 283 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
272 m_provider = client->provider(); 284 m_provider = client->provider();
273 if (m_provider) 285 if (m_provider)
274 m_provider->setClient(this); 286 m_provider->setClient(this);
275 } 287 }
276 } 288 }
277 289
278 } // namespace blink 290 } // namespace blink
OLDNEW
« 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