| OLD | NEW |
| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 "The document is in an invalid " | 275 "The document is in an invalid " |
| 276 "state.")); | 276 "state.")); |
| 277 return promise; | 277 return promise; |
| 278 } | 278 } |
| 279 | 279 |
| 280 ExecutionContext* executionContext = scriptState->getExecutionContext(); | 280 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
| 281 // FIXME: May be null due to worker termination: http://crbug.com/413518. | 281 // FIXME: May be null due to worker termination: http://crbug.com/413518. |
| 282 if (!executionContext) | 282 if (!executionContext) |
| 283 return ScriptPromise(); | 283 return ScriptPromise(); |
| 284 | 284 |
| 285 KURL scriptURL = | 285 KURL scriptURL = executionContext->completeURL(url); |
| 286 enteredExecutionContext(scriptState->isolate())->completeURL(url); | |
| 287 scriptURL.removeFragmentIdentifier(); | 286 scriptURL.removeFragmentIdentifier(); |
| 288 | 287 |
| 289 KURL patternURL; | 288 KURL patternURL; |
| 290 if (options.scope().isNull()) | 289 if (options.scope().isNull()) |
| 291 patternURL = KURL(scriptURL, "./"); | 290 patternURL = KURL(scriptURL, "./"); |
| 292 else | 291 else |
| 293 patternURL = enteredExecutionContext(scriptState->isolate()) | 292 patternURL = executionContext->completeURL(options.scope()); |
| 294 ->completeURL(options.scope()); | |
| 295 | 293 |
| 296 registerServiceWorkerImpl( | 294 registerServiceWorkerImpl( |
| 297 executionContext, scriptURL, patternURL, | 295 executionContext, scriptURL, patternURL, |
| 298 WTF::makeUnique<CallbackPromiseAdapter<ServiceWorkerRegistration, | 296 WTF::makeUnique<CallbackPromiseAdapter<ServiceWorkerRegistration, |
| 299 ServiceWorkerErrorForUpdate>>( | 297 ServiceWorkerErrorForUpdate>>( |
| 300 resolver)); | 298 resolver)); |
| 301 | 299 |
| 302 return promise; | 300 return promise; |
| 303 } | 301 } |
| 304 | 302 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 332 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers( | 330 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers( |
| 333 pageURL.protocol())) { | 331 pageURL.protocol())) { |
| 334 resolver->reject(DOMException::create( | 332 resolver->reject(DOMException::create( |
| 335 SecurityError, | 333 SecurityError, |
| 336 "Failed to get a ServiceWorkerRegistration: The URL protocol of the " | 334 "Failed to get a ServiceWorkerRegistration: The URL protocol of the " |
| 337 "current origin ('" + | 335 "current origin ('" + |
| 338 documentOrigin->toString() + "') is not supported.")); | 336 documentOrigin->toString() + "') is not supported.")); |
| 339 return promise; | 337 return promise; |
| 340 } | 338 } |
| 341 | 339 |
| 342 KURL completedURL = | 340 KURL completedURL = executionContext->completeURL(documentURL); |
| 343 enteredExecutionContext(scriptState->isolate())->completeURL(documentURL); | |
| 344 completedURL.removeFragmentIdentifier(); | 341 completedURL.removeFragmentIdentifier(); |
| 345 if (!documentOrigin->canRequest(completedURL)) { | 342 if (!documentOrigin->canRequest(completedURL)) { |
| 346 RefPtr<SecurityOrigin> documentURLOrigin = | 343 RefPtr<SecurityOrigin> documentURLOrigin = |
| 347 SecurityOrigin::create(completedURL); | 344 SecurityOrigin::create(completedURL); |
| 348 resolver->reject( | 345 resolver->reject( |
| 349 DOMException::create(SecurityError, | 346 DOMException::create(SecurityError, |
| 350 "Failed to get a ServiceWorkerRegistration: The " | 347 "Failed to get a ServiceWorkerRegistration: The " |
| 351 "origin of the provided documentURL ('" + | 348 "origin of the provided documentURL ('" + |
| 352 documentURLOrigin->toString() + | 349 documentURLOrigin->toString() + |
| 353 "') does not match the current origin ('" + | 350 "') does not match the current origin ('" + |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 482 |
| 486 if (ServiceWorkerContainerClient* client = | 483 if (ServiceWorkerContainerClient* client = |
| 487 ServiceWorkerContainerClient::from(executionContext)) { | 484 ServiceWorkerContainerClient::from(executionContext)) { |
| 488 m_provider = client->provider(); | 485 m_provider = client->provider(); |
| 489 if (m_provider) | 486 if (m_provider) |
| 490 m_provider->setClient(this); | 487 m_provider->setClient(this); |
| 491 } | 488 } |
| 492 } | 489 } |
| 493 | 490 |
| 494 } // namespace blink | 491 } // namespace blink |
| OLD | NEW |