summaryrefslogtreecommitdiff
path: root/Source/WebCore/workers/AbstractWorker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/workers/AbstractWorker.cpp')
-rw-r--r--Source/WebCore/workers/AbstractWorker.cpp48
1 files changed, 14 insertions, 34 deletions
diff --git a/Source/WebCore/workers/AbstractWorker.cpp b/Source/WebCore/workers/AbstractWorker.cpp
index 85b9b5408..39b95d0eb 100644
--- a/Source/WebCore/workers/AbstractWorker.cpp
+++ b/Source/WebCore/workers/AbstractWorker.cpp
@@ -29,55 +29,35 @@
*/
#include "config.h"
-
#include "AbstractWorker.h"
#include "ContentSecurityPolicy.h"
-#include "ErrorEvent.h"
-#include "Event.h"
-#include "EventException.h"
-#include "EventNames.h"
#include "ExceptionCode.h"
-#include "InspectorInstrumentation.h"
#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
namespace WebCore {
-AbstractWorker::AbstractWorker(ScriptExecutionContext& context)
- : ActiveDOMObject(&context)
-{
-}
-
-AbstractWorker::~AbstractWorker()
+ExceptionOr<URL> AbstractWorker::resolveURL(const String& url, bool shouldBypassMainWorldContentSecurityPolicy)
{
-}
+ if (url.isEmpty())
+ return Exception { SYNTAX_ERR };
-URL AbstractWorker::resolveURL(const String& url, ExceptionCode& ec)
-{
- if (url.isEmpty()) {
- ec = SYNTAX_ERR;
- return URL();
- }
+ auto& context = *scriptExecutionContext();
- // FIXME: This should use the dynamic global scope (bug #27887)
- URL scriptURL = scriptExecutionContext()->completeURL(url);
- if (!scriptURL.isValid()) {
- ec = SYNTAX_ERR;
- return URL();
- }
+ // FIXME: This should use the dynamic global scope (bug #27887).
+ URL scriptURL = context.completeURL(url);
+ if (!scriptURL.isValid())
+ return Exception { SYNTAX_ERR };
- if (!scriptExecutionContext()->securityOrigin()->canRequest(scriptURL)) {
- ec = SECURITY_ERR;
- return URL();
- }
+ if (!context.securityOrigin()->canRequest(scriptURL))
+ return Exception { SECURITY_ERR };
- if (scriptExecutionContext()->contentSecurityPolicy() && !scriptExecutionContext()->contentSecurityPolicy()->allowScriptFromSource(scriptURL)) {
- ec = SECURITY_ERR;
- return URL();
- }
+ ASSERT(context.contentSecurityPolicy());
+ if (!shouldBypassMainWorldContentSecurityPolicy && !context.contentSecurityPolicy()->allowChildContextFromSource(scriptURL))
+ return Exception { SECURITY_ERR };
- return scriptURL;
+ return WTFMove(scriptURL);
}
} // namespace WebCore