OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) | 199 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) |
200 { | 200 { |
201 ASSERT(contentSecurityPolicy()); | 201 ASSERT(contentSecurityPolicy()); |
202 Vector<String>::const_iterator urlsEnd = urls.end(); | 202 Vector<String>::const_iterator urlsEnd = urls.end(); |
203 Vector<KURL> completedURLs; | 203 Vector<KURL> completedURLs; |
204 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ | 204 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ |
205 const KURL& url = executionContext()->completeURL(*it); | 205 const KURL& url = executionContext()->completeURL(*it); |
206 if (!url.isValid()) { | 206 if (!url.isValid()) { |
207 exceptionState.throwDOMException(SyntaxError, "Failed to execute 'im
portScripts': the URL '" + *it + "' is invalid."); | 207 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "'
is invalid."); |
208 return; | 208 return; |
209 } | 209 } |
210 completedURLs.append(url); | 210 completedURLs.append(url); |
211 } | 211 } |
212 Vector<KURL>::const_iterator end = completedURLs.end(); | 212 Vector<KURL>::const_iterator end = completedURLs.end(); |
213 | 213 |
214 for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++i
t) { | 214 for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++i
t) { |
215 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create()); | 215 RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create()); |
216 scriptLoader->setTargetType(ResourceRequest::TargetIsScript); | 216 scriptLoader->setTargetType(ResourceRequest::TargetIsScript); |
217 scriptLoader->loadSynchronously(executionContext(), *it, AllowCrossOrigi
nRequests); | 217 scriptLoader->loadSynchronously(executionContext(), *it, AllowCrossOrigi
nRequests); |
218 | 218 |
219 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. | 219 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. |
220 if (scriptLoader->failed()) { | 220 if (scriptLoader->failed()) { |
221 exceptionState.throwDOMException(NetworkError, "Failed to execute 'i
mportScripts': the script at '" + it->elidedString() + "' failed to load."); | 221 exceptionState.throwDOMException(NetworkError, "The script at '" + i
t->elidedString() + "' failed to load."); |
222 return; | 222 return; |
223 } | 223 } |
224 | 224 |
225 InspectorInstrumentation::scriptImported(executionContext(), scriptLoade
r->identifier(), scriptLoader->script()); | 225 InspectorInstrumentation::scriptImported(executionContext(), scriptLoade
r->identifier(), scriptLoader->script()); |
226 | 226 |
227 RefPtr<ErrorEvent> errorEvent; | 227 RefPtr<ErrorEvent> errorEvent; |
228 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent); | 228 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent); |
229 if (errorEvent) { | 229 if (errorEvent) { |
230 m_script->rethrowExceptionFromImportedScript(errorEvent.release()); | 230 m_script->rethrowExceptionFromImportedScript(errorEvent.release()); |
231 return; | 231 return; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 { | 328 { |
329 return script()->idleNotification(); | 329 return script()->idleNotification(); |
330 } | 330 } |
331 | 331 |
332 WorkerEventQueue* WorkerGlobalScope::eventQueue() const | 332 WorkerEventQueue* WorkerGlobalScope::eventQueue() const |
333 { | 333 { |
334 return m_eventQueue.get(); | 334 return m_eventQueue.get(); |
335 } | 335 } |
336 | 336 |
337 } // namespace WebCore | 337 } // namespace WebCore |
OLD | NEW |