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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerClients.cpp

Issue 985633003: Service Worker: Clients.openWindow() should allow opening x-origin URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months 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/http/tests/serviceworker/chromium/resources/clients-openwindow.js ('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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/serviceworkers/ServiceWorkerClients.h" 6 #include "modules/serviceworkers/ServiceWorkerClients.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 101 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
102 ScriptPromise promise = resolver->promise(); 102 ScriptPromise promise = resolver->promise();
103 ExecutionContext* context = scriptState->executionContext(); 103 ExecutionContext* context = scriptState->executionContext();
104 104
105 KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url); 105 KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url);
106 if (!parsedUrl.isValid()) { 106 if (!parsedUrl.isValid()) {
107 resolver->reject(DOMException::create(SyntaxError, "'" + url + "' is not a valid URL.")); 107 resolver->reject(DOMException::create(SyntaxError, "'" + url + "' is not a valid URL."));
108 return promise; 108 return promise;
109 } 109 }
110 110
111 if (!context->securityOrigin()->canRequest(parsedUrl)) {
112 resolver->reject(DOMException::create(SecurityError, "'" + parsedUrl.eli dedString() + "' is not same-origin with the Worker."));
113 return promise;
114 }
115
116 if (!context->isWindowInteractionAllowed()) { 111 if (!context->isWindowInteractionAllowed()) {
117 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o open a window.")); 112 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o open a window."));
118 return promise; 113 return promise;
119 } 114 }
120 context->consumeWindowInteraction(); 115 context->consumeWindowInteraction();
121 116
122 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Cal lbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>(resolver)); 117 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Cal lbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>(resolver));
123 return promise; 118 return promise;
124 } 119 }
125 120
126 } // namespace blink 121 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/clients-openwindow.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698