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

Side by Side Diff: Source/core/workers/AbstractWorker.cpp

Issue 23283009: Convert SecurityError exceptions to 'es.throwSecurityError()'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return KURL(); 61 return KURL();
62 } 62 }
63 63
64 // FIXME: This should use the dynamic global scope (bug #27887) 64 // FIXME: This should use the dynamic global scope (bug #27887)
65 KURL scriptURL = scriptExecutionContext()->completeURL(url); 65 KURL scriptURL = scriptExecutionContext()->completeURL(url);
66 if (!scriptURL.isValid()) { 66 if (!scriptURL.isValid()) {
67 es.throwDOMException(SyntaxError, "Failed to create a worker: '" + url + "' is not a valid URL."); 67 es.throwDOMException(SyntaxError, "Failed to create a worker: '" + url + "' is not a valid URL.");
68 return KURL(); 68 return KURL();
69 } 69 }
70 70
71 // We can safely expose the URL in the following exceptions, as these checks happen synchronously before redirection. JavaScript receives no new information .
71 if (!scriptExecutionContext()->securityOrigin()->canRequest(scriptURL)) { 72 if (!scriptExecutionContext()->securityOrigin()->canRequest(scriptURL)) {
72 es.throwDOMException(SecurityError, "Failed to create a worker: script w ith origin '" + SecurityOrigin::create(scriptURL)->toString() + "' cannot be acc essed from origin '" + scriptExecutionContext()->securityOrigin()->toString() + "'."); 73 es.throwSecurityError("Failed to create a worker: script at '" + scriptU RL.elidedString() + "' cannot be accessed from origin '" + scriptExecutionContex t()->securityOrigin()->toString() + "'.");
73 return KURL(); 74 return KURL();
74 } 75 }
75 76
76 if (scriptExecutionContext()->contentSecurityPolicy() && !scriptExecutionCon text()->contentSecurityPolicy()->allowScriptFromSource(scriptURL)) { 77 if (scriptExecutionContext()->contentSecurityPolicy() && !scriptExecutionCon text()->contentSecurityPolicy()->allowScriptFromSource(scriptURL)) {
77 es.throwDOMException(SecurityError, "Failed to create a worker: access t o the script at '" + url + "' is denied by the document's Content Security Polic y."); 78 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.");
78 return KURL(); 79 return KURL();
79 } 80 }
80 81
81 return scriptURL; 82 return scriptURL;
82 } 83 }
83 84
84 EventTargetData* AbstractWorker::eventTargetData() 85 EventTargetData* AbstractWorker::eventTargetData()
85 { 86 {
86 return &m_eventTargetData; 87 return &m_eventTargetData;
87 } 88 }
88 89
89 EventTargetData* AbstractWorker::ensureEventTargetData() 90 EventTargetData* AbstractWorker::ensureEventTargetData()
90 { 91 {
91 return &m_eventTargetData; 92 return &m_eventTargetData;
92 } 93 }
93 94
94 } // namespace WebCore 95 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698