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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return promise; | 128 return promise; |
129 } | 129 } |
130 | 130 |
131 KURL scriptURL = executionContext->completeURL(url); | 131 KURL scriptURL = executionContext->completeURL(url); |
132 scriptURL.removeFragmentIdentifier(); | 132 scriptURL.removeFragmentIdentifier(); |
133 if (!documentOrigin->canRequest(scriptURL)) { | 133 if (!documentOrigin->canRequest(scriptURL)) { |
134 resolver->reject(DOMException::create(SecurityError, "The origin of the
script must match the current origin.")); | 134 resolver->reject(DOMException::create(SecurityError, "The origin of the
script must match the current origin.")); |
135 return promise; | 135 return promise; |
136 } | 136 } |
137 | 137 |
138 if (!patternURL.string().startsWith(scriptURL.baseAsString())) { | |
139 resolver->reject(DOMException::create(SecurityError, "The scope must be
under the directory of the script URL.")); | |
140 return promise; | |
141 } | |
142 | |
143 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise
Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver)); | 138 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise
Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver)); |
144 | 139 |
145 return promise; | 140 return promise; |
146 } | 141 } |
147 | 142 |
148 class BooleanValue { | 143 class BooleanValue { |
149 public: | 144 public: |
150 typedef bool WebType; | 145 typedef bool WebType; |
151 static bool take(ScriptPromiseResolver* resolver, WebType* boolean) | 146 static bool take(ScriptPromiseResolver* resolver, WebType* boolean) |
152 { | 147 { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 m_ready = createReadyProperty(); | 257 m_ready = createReadyProperty(); |
263 | 258 |
264 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 259 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
265 m_provider = client->provider(); | 260 m_provider = client->provider(); |
266 if (m_provider) | 261 if (m_provider) |
267 m_provider->setClient(this); | 262 m_provider->setClient(this); |
268 } | 263 } |
269 } | 264 } |
270 | 265 |
271 } // namespace blink | 266 } // namespace blink |
OLD | NEW |