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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 { | 110 { |
111 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); | 111 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); |
112 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | 112 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); |
113 ScriptPromise promise = resolver->promise(); | 113 ScriptPromise promise = resolver->promise(); |
114 | 114 |
115 if (!m_provider) { | 115 if (!m_provider) { |
116 resolver->reject(DOMException::create(InvalidStateError, "The document i s in an invalid state.")); | 116 resolver->reject(DOMException::create(InvalidStateError, "The document i s in an invalid state.")); |
117 return promise; | 117 return promise; |
118 } | 118 } |
119 | 119 |
120 // FIXME: This should use the container's execution context, not | |
121 // the callers. | |
122 ExecutionContext* executionContext = scriptState->executionContext(); | 120 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
| |
123 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); | 121 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
124 String errorMessage; | 122 String errorMessage; |
125 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { | 123 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { |
126 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); | 124 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); |
127 return promise; | 125 return promise; |
128 } | 126 } |
129 | 127 |
130 KURL pageURL = KURL(KURL(), documentOrigin->toString()); | 128 KURL pageURL = KURL(KURL(), documentOrigin->toString()); |
131 if (!pageURL.protocolIsInHTTPFamily()) { | 129 if (!pageURL.protocolIsInHTTPFamily()) { |
132 resolver->reject(DOMException::create(SecurityError, "The URL protocol o f the current origin is not supported: " + pageURL.protocol())); | 130 resolver->reject(DOMException::create(SecurityError, "The URL protocol o f the current origin is not supported: " + pageURL.protocol())); |
133 return promise; | 131 return promise; |
134 } | 132 } |
135 | 133 |
136 KURL patternURL = executionContext->completeURL(options.scope()); | 134 Document* callingDocument = callingDOMWindow(scriptState->isolate())->docume nt(); |
135 | |
136 KURL patternURL = callingDocument ? callingDocument->completeURL(options.sco pe()) : 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
| |
137 patternURL.removeFragmentIdentifier(); | 137 patternURL.removeFragmentIdentifier(); |
138 if (!documentOrigin->canRequest(patternURL)) { | 138 if (!documentOrigin->canRequest(patternURL)) { |
139 resolver->reject(DOMException::create(SecurityError, "The scope must mat ch the current origin.")); | 139 resolver->reject(DOMException::create(SecurityError, "The scope must mat ch the current origin.")); |
140 return promise; | 140 return promise; |
141 } | 141 } |
142 | 142 |
143 KURL scriptURL = executionContext->completeURL(url); | 143 KURL scriptURL = callingDocument ? callingDocument->completeURL(url) : execu tionContext->completeURL(url); |
144 scriptURL.removeFragmentIdentifier(); | 144 scriptURL.removeFragmentIdentifier(); |
145 if (!documentOrigin->canRequest(scriptURL)) { | 145 if (!documentOrigin->canRequest(scriptURL)) { |
146 resolver->reject(DOMException::create(SecurityError, "The origin of the script must match the current origin.")); | 146 resolver->reject(DOMException::create(SecurityError, "The origin of the script must match the current origin.")); |
147 return promise; | 147 return promise; |
148 } | 148 } |
149 | 149 |
150 if (!patternURL.string().startsWith(scriptURL.baseAsString())) { | 150 if (!patternURL.string().startsWith(scriptURL.baseAsString())) { |
151 resolver->reject(DOMException::create(SecurityError, "The scope must be under the directory of the script URL.")); | 151 resolver->reject(DOMException::create(SecurityError, "The scope must be under the directory of the script URL.")); |
152 return promise; | 152 return promise; |
153 } | 153 } |
(...skipping 20 matching lines...) Expand all Loading... | |
174 { | 174 { |
175 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); | 175 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); |
176 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | 176 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); |
177 ScriptPromise promise = resolver->promise(); | 177 ScriptPromise promise = resolver->promise(); |
178 | 178 |
179 if (!m_provider) { | 179 if (!m_provider) { |
180 resolver->reject(DOMException::create(InvalidStateError, "The document i s in an invalid state.")); | 180 resolver->reject(DOMException::create(InvalidStateError, "The document i s in an invalid state.")); |
181 return promise; | 181 return promise; |
182 } | 182 } |
183 | 183 |
184 // FIXME: This should use the container's execution context, not | |
185 // the callers. | |
186 ExecutionContext* executionContext = scriptState->executionContext(); | 184 ExecutionContext* executionContext = scriptState->executionContext(); |
187 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); | 185 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
188 String errorMessage; | 186 String errorMessage; |
189 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { | 187 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { |
190 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); | 188 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); |
191 return promise; | 189 return promise; |
192 } | 190 } |
193 | 191 |
194 KURL pageURL = KURL(KURL(), documentOrigin->toString()); | 192 KURL pageURL = KURL(KURL(), documentOrigin->toString()); |
195 if (!pageURL.protocolIsInHTTPFamily()) { | 193 if (!pageURL.protocolIsInHTTPFamily()) { |
196 resolver->reject(DOMException::create(SecurityError, "The URL protocol o f the current origin is not supported: " + pageURL.protocol())); | 194 resolver->reject(DOMException::create(SecurityError, "The URL protocol o f the current origin is not supported: " + pageURL.protocol())); |
197 return promise; | 195 return promise; |
198 } | 196 } |
199 | 197 |
200 KURL completedURL = executionContext->completeURL(documentURL); | 198 Document* callingDocument = callingDOMWindow(scriptState->isolate())->docume nt(); |
199 KURL completedURL = callingDocument ? callingDocument->completeURL(documentU RL) : executionContext->completeURL(documentURL); | |
201 completedURL.removeFragmentIdentifier(); | 200 completedURL.removeFragmentIdentifier(); |
202 if (!documentOrigin->canRequest(completedURL)) { | 201 if (!documentOrigin->canRequest(completedURL)) { |
203 resolver->reject(DOMException::create(SecurityError, "The documentURL mu st match the current origin.")); | 202 resolver->reject(DOMException::create(SecurityError, "The documentURL mu st match the current origin.")); |
204 return promise; | 203 return promise; |
205 } | 204 } |
206 m_provider->getRegistration(completedURL, new GetRegistrationCallback(resolv er)); | 205 m_provider->getRegistration(completedURL, new GetRegistrationCallback(resolv er)); |
207 | 206 |
208 return promise; | 207 return promise; |
209 } | 208 } |
210 | 209 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 m_ready = createReadyProperty(); | 311 m_ready = createReadyProperty(); |
313 | 312 |
314 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { | 313 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { |
315 m_provider = client->provider(); | 314 m_provider = client->provider(); |
316 if (m_provider) | 315 if (m_provider) |
317 m_provider->setClient(this); | 316 m_provider->setClient(this); |
318 } | 317 } |
319 } | 318 } |
320 | 319 |
321 } // namespace blink | 320 } // namespace blink |
OLD | NEW |