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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 1532463003: ServiceWorker: Reject SecurityError instead of NotSupportedError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 ExecutionContext* executionContext = scriptState->executionContext(); 204 ExecutionContext* executionContext = scriptState->executionContext();
205 // FIXME: May be null due to worker termination: http://crbug.com/413518. 205 // FIXME: May be null due to worker termination: http://crbug.com/413518.
206 if (!executionContext) 206 if (!executionContext)
207 return ScriptPromise(); 207 return ScriptPromise();
208 208
209 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 209 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
210 String errorMessage; 210 String errorMessage;
211 // Restrict to secure origins: https://w3c.github.io/webappsec/specs/powerfu lfeatures/#settings-privileged 211 // Restrict to secure origins: https://w3c.github.io/webappsec/specs/powerfu lfeatures/#settings-privileged
212 if (!executionContext->isSecureContext(errorMessage)) { 212 if (!executionContext->isSecureContext(errorMessage)) {
213 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 213 resolver->reject(DOMException::create(SecurityError, errorMessage));
214 return promise; 214 return promise;
215 } 215 }
216 216
217 KURL pageURL = KURL(KURL(), documentOrigin->toString()); 217 KURL pageURL = KURL(KURL(), documentOrigin->toString());
218 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) { 218 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) {
219 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the current origin ('" + documentOrigin->t oString() + "') is not supported.")); 219 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the current origin ('" + documentOrigin->t oString() + "') is not supported."));
220 return promise; 220 return promise;
221 } 221 }
222 222
223 KURL scriptURL = callingExecutionContext(scriptState->isolate())->completeUR L(url); 223 KURL scriptURL = callingExecutionContext(scriptState->isolate())->completeUR L(url);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 272
273 ExecutionContext* executionContext = scriptState->executionContext(); 273 ExecutionContext* executionContext = scriptState->executionContext();
274 // FIXME: May be null due to worker termination: http://crbug.com/413518. 274 // FIXME: May be null due to worker termination: http://crbug.com/413518.
275 if (!executionContext) 275 if (!executionContext)
276 return ScriptPromise(); 276 return ScriptPromise();
277 277
278 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 278 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
279 String errorMessage; 279 String errorMessage;
280 if (!executionContext->isSecureContext(errorMessage)) { 280 if (!executionContext->isSecureContext(errorMessage)) {
281 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 281 resolver->reject(DOMException::create(SecurityError, errorMessage));
282 return promise; 282 return promise;
283 } 283 }
284 284
285 KURL pageURL = KURL(KURL(), documentOrigin->toString()); 285 KURL pageURL = KURL(KURL(), documentOrigin->toString());
286 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) { 286 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) {
287 resolver->reject(DOMException::create(SecurityError, "Failed to get a Se rviceWorkerRegistration: The URL protocol of the current origin ('" + documentOr igin->toString() + "') is not supported.")); 287 resolver->reject(DOMException::create(SecurityError, "Failed to get a Se rviceWorkerRegistration: The URL protocol of the current origin ('" + documentOr igin->toString() + "') is not supported."));
288 return promise; 288 return promise;
289 } 289 }
290 290
291 KURL completedURL = callingExecutionContext(scriptState->isolate())->complet eURL(documentURL); 291 KURL completedURL = callingExecutionContext(scriptState->isolate())->complet eURL(documentURL);
(...skipping 15 matching lines...) Expand all
307 307
308 if (!m_provider) { 308 if (!m_provider) {
309 resolver->reject(DOMException::create(InvalidStateError, "Failed to get ServiceWorkerRegistration objects: The document is in an invalid state.")); 309 resolver->reject(DOMException::create(InvalidStateError, "Failed to get ServiceWorkerRegistration objects: The document is in an invalid state."));
310 return promise; 310 return promise;
311 } 311 }
312 312
313 ExecutionContext* executionContext = scriptState->executionContext(); 313 ExecutionContext* executionContext = scriptState->executionContext();
314 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 314 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
315 String errorMessage; 315 String errorMessage;
316 if (!executionContext->isSecureContext(errorMessage)) { 316 if (!executionContext->isSecureContext(errorMessage)) {
317 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 317 resolver->reject(DOMException::create(SecurityError, errorMessage));
318 return promise; 318 return promise;
319 } 319 }
320 320
321 KURL pageURL = KURL(KURL(), documentOrigin->toString()); 321 KURL pageURL = KURL(KURL(), documentOrigin->toString());
322 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) { 322 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) {
323 resolver->reject(DOMException::create(SecurityError, "Failed to get Serv iceWorkerRegistration objects: The URL protocol of the current origin ('" + docu mentOrigin->toString() + "') is not supported.")); 323 resolver->reject(DOMException::create(SecurityError, "Failed to get Serv iceWorkerRegistration objects: The URL protocol of the current origin ('" + docu mentOrigin->toString() + "') is not supported."));
324 return promise; 324 return promise;
325 } 325 }
326 326
327 m_provider->getRegistrations(new GetRegistrationsCallback(resolver)); 327 m_provider->getRegistrations(new GetRegistrationsCallback(resolver));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return; 390 return;
391 391
392 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 392 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
393 m_provider = client->provider(); 393 m_provider = client->provider();
394 if (m_provider) 394 if (m_provider)
395 m_provider->setClient(this); 395 m_provider->setClient(this);
396 } 396 }
397 } 397 }
398 398
399 } // namespace blink 399 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698