| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 AbstractWorker::AbstractWorker(ExecutionContext* context) | 43 AbstractWorker::AbstractWorker(ExecutionContext* context) |
| 44 : ActiveDOMObject(context) | 44 : ActiveDOMObject(context) |
| 45 { | 45 { |
| 46 } | 46 } |
| 47 | 47 |
| 48 AbstractWorker::~AbstractWorker() | 48 AbstractWorker::~AbstractWorker() |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 | 51 |
| 52 KURL AbstractWorker::resolveURL(const String& url, ExceptionState& es) | 52 KURL AbstractWorker::resolveURL(const String& url, ExceptionState& exceptionStat
e) |
| 53 { | 53 { |
| 54 if (url.isEmpty()) { | 54 if (url.isEmpty()) { |
| 55 es.throwDOMException(SyntaxError, "Failed to create a worker: an empty U
RL was provided."); | 55 exceptionState.throwDOMException(SyntaxError, "Failed to create a worker
: an empty URL was provided."); |
| 56 return KURL(); | 56 return KURL(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // FIXME: This should use the dynamic global scope (bug #27887) | 59 // FIXME: This should use the dynamic global scope (bug #27887) |
| 60 KURL scriptURL = executionContext()->completeURL(url); | 60 KURL scriptURL = executionContext()->completeURL(url); |
| 61 if (!scriptURL.isValid()) { | 61 if (!scriptURL.isValid()) { |
| 62 es.throwDOMException(SyntaxError, "Failed to create a worker: '" + url +
"' is not a valid URL."); | 62 exceptionState.throwDOMException(SyntaxError, "Failed to create a worker
: '" + url + "' is not a valid URL."); |
| 63 return KURL(); | 63 return KURL(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // We can safely expose the URL in the following exceptions, as these checks
happen synchronously before redirection. JavaScript receives no new information
. | 66 // We can safely expose the URL in the following exceptions, as these checks
happen synchronously before redirection. JavaScript receives no new information
. |
| 67 if (!executionContext()->securityOrigin()->canRequest(scriptURL)) { | 67 if (!executionContext()->securityOrigin()->canRequest(scriptURL)) { |
| 68 es.throwSecurityError("Failed to create a worker: script at '" + scriptU
RL.elidedString() + "' cannot be accessed from origin '" + executionContext()->s
ecurityOrigin()->toString() + "'."); | 68 exceptionState.throwSecurityError("Failed to create a worker: script at
'" + scriptURL.elidedString() + "' cannot be accessed from origin '" + execution
Context()->securityOrigin()->toString() + "'."); |
| 69 return KURL(); | 69 return KURL(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 if (executionContext()->contentSecurityPolicy() && !executionContext()->cont
entSecurityPolicy()->allowScriptFromSource(scriptURL)) { | 72 if (executionContext()->contentSecurityPolicy() && !executionContext()->cont
entSecurityPolicy()->allowScriptFromSource(scriptURL)) { |
| 73 es.throwSecurityError("Failed to create a worker: access to the script a
t '" + scriptURL.elidedString() + "' is denied by the document's Content Securit
y Policy."); | 73 exceptionState.throwSecurityError("Failed to create a worker: access to
the script at '" + scriptURL.elidedString() + "' is denied by the document's Con
tent Security Policy."); |
| 74 return KURL(); | 74 return KURL(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 return scriptURL; | 77 return scriptURL; |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace WebCore | 80 } // namespace WebCore |
| OLD | NEW |