Chromium Code Reviews| Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| index 5bbf765d400c68d6259cd439aba44e8680e1c863..cfcb4ff88dcea8fd5bf6aea7d27b744c4783e9a5 100644 |
| --- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| +++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| @@ -117,8 +117,6 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS |
| return promise; |
| } |
| - // FIXME: This should use the container's execution context, not |
| - // the callers. |
| ExecutionContext* executionContext = scriptState->executionContext(); |
|
dominicc (has gone to gerrit)
2015/02/09 07:31:48
I'm still not sure this is the right context. Whic
jungkees
2015/02/13 08:12:37
Having double-checked it, it's basically the conta
|
| RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
| String errorMessage; |
| @@ -133,14 +131,16 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS |
| return promise; |
| } |
| - KURL patternURL = executionContext->completeURL(options.scope()); |
| + Document* callingDocument = callingDOMWindow(scriptState->isolate())->document(); |
| + |
| + KURL patternURL = callingDocument ? callingDocument->completeURL(options.scope()) : executionContext->completeURL(options.scope()); |
|
dominicc (has gone to gerrit)
2015/02/09 07:31:48
I don't think this in right; I think if from frame
jungkees
2015/02/13 08:12:38
This is not register specific, but HTML specifies
dominicc (has gone to gerrit)
2015/02/16 06:54:45
On 2015/02/13 at 08:12:38, jungkees wrote:
jungkees
2015/02/16 09:06:10
My intention with checking whether the callingDocu
|
| patternURL.removeFragmentIdentifier(); |
| if (!documentOrigin->canRequest(patternURL)) { |
| resolver->reject(DOMException::create(SecurityError, "The scope must match the current origin.")); |
| return promise; |
| } |
| - KURL scriptURL = executionContext->completeURL(url); |
| + KURL scriptURL = callingDocument ? callingDocument->completeURL(url) : executionContext->completeURL(url); |
| scriptURL.removeFragmentIdentifier(); |
| if (!documentOrigin->canRequest(scriptURL)) { |
| resolver->reject(DOMException::create(SecurityError, "The origin of the script must match the current origin.")); |
| @@ -181,8 +181,6 @@ ScriptPromise ServiceWorkerContainer::getRegistration(ScriptState* scriptState, |
| return promise; |
| } |
| - // FIXME: This should use the container's execution context, not |
| - // the callers. |
| ExecutionContext* executionContext = scriptState->executionContext(); |
| RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
| String errorMessage; |
| @@ -197,7 +195,8 @@ ScriptPromise ServiceWorkerContainer::getRegistration(ScriptState* scriptState, |
| return promise; |
| } |
| - KURL completedURL = executionContext->completeURL(documentURL); |
| + Document* callingDocument = callingDOMWindow(scriptState->isolate())->document(); |
| + KURL completedURL = callingDocument ? callingDocument->completeURL(documentURL) : executionContext->completeURL(documentURL); |
| completedURL.removeFragmentIdentifier(); |
| if (!documentOrigin->canRequest(completedURL)) { |
| resolver->reject(DOMException::create(SecurityError, "The documentURL must match the current origin.")); |