summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/DEPS1
-rw-r--r--content/browser/devtools/shared_worker_devtools_manager_unittest.cc44
-rw-r--r--content/browser/shared_worker/shared_worker_instance.cc10
-rw-r--r--content/browser/shared_worker/shared_worker_instance.h19
-rw-r--r--content/browser/shared_worker/shared_worker_instance_unittest.cc22
-rw-r--r--content/browser/shared_worker/shared_worker_service_impl.cc22
-rw-r--r--content/browser/shared_worker/shared_worker_service_impl_unittest.cc2
-rw-r--r--content/common/DEPS1
-rw-r--r--content/common/content_param_traits_macros.h3
-rw-r--r--content/common/view_messages.h5
-rw-r--r--content/renderer/shared_worker_repository.cc2
-rw-r--r--content/renderer/shared_worker_repository.h2
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker-in-iframe.html30
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker.html15
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/workers/shared-worker-secure-context.https.html31
-rw-r--r--third_party/WebKit/Source/web/SharedWorkerRepositoryClientImpl.cpp19
-rw-r--r--third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h23
-rw-r--r--third_party/WebKit/public/web/WebSharedWorkerRepositoryClient.h3
18 files changed, 194 insertions, 60 deletions
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 42ad828..be56167 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -87,6 +87,7 @@ include_rules = [
"+third_party/WebKit/public/web/WebPopupType.h",
"+third_party/WebKit/public/web/WebSandboxFlags.h",
"+third_party/WebKit/public/web/WebSerializedScriptValueVersion.h",
+ "+third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h",
"+third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h",
"+third_party/WebKit/public/web/WebTextDirection.h",
"+third_party/WebKit/public/web/WebTextInputType.h",
diff --git a/content/browser/devtools/shared_worker_devtools_manager_unittest.cc b/content/browser/devtools/shared_worker_devtools_manager_unittest.cc
index b56c07b..554b83e 100644
--- a/content/browser/devtools/shared_worker_devtools_manager_unittest.cc
+++ b/content/browser/devtools/shared_worker_devtools_manager_unittest.cc
@@ -97,12 +97,11 @@ class SharedWorkerDevToolsManagerTest : public testing::Test {
TEST_F(SharedWorkerDevToolsManagerTest, BasicTest) {
scoped_refptr<DevToolsAgentHostImpl> agent_host;
- SharedWorkerInstance instance1(GURL("http://example.com/w.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- partition_id_);
+ SharedWorkerInstance instance1(
+ GURL("http://example.com/w.js"), base::string16(), base::string16(),
+ blink::WebContentSecurityPolicyTypeReport,
+ browser_context_->GetResourceContext(), partition_id_,
+ blink::WebSharedWorkerCreationContextTypeNonsecure);
agent_host = manager_->GetDevToolsAgentHostForWorker(1, 1);
EXPECT_FALSE(agent_host.get());
@@ -180,18 +179,16 @@ TEST_F(SharedWorkerDevToolsManagerTest, AttachTest) {
scoped_refptr<DevToolsAgentHostImpl> agent_host1;
scoped_refptr<DevToolsAgentHostImpl> agent_host2;
- SharedWorkerInstance instance1(GURL("http://example.com/w1.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- partition_id_);
- SharedWorkerInstance instance2(GURL("http://example.com/w2.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- partition_id_);
+ SharedWorkerInstance instance1(
+ GURL("http://example.com/w1.js"), base::string16(), base::string16(),
+ blink::WebContentSecurityPolicyTypeReport,
+ browser_context_->GetResourceContext(), partition_id_,
+ blink::WebSharedWorkerCreationContextTypeNonsecure);
+ SharedWorkerInstance instance2(
+ GURL("http://example.com/w2.js"), base::string16(), base::string16(),
+ blink::WebContentSecurityPolicyTypeReport,
+ browser_context_->GetResourceContext(), partition_id_,
+ blink::WebSharedWorkerCreationContextTypeNonsecure);
// Created -> GetDevToolsAgentHost -> Register -> Started -> Destroyed
scoped_ptr<TestDevToolsClientHost> client_host1(new TestDevToolsClientHost());
@@ -265,12 +262,11 @@ TEST_F(SharedWorkerDevToolsManagerTest, AttachTest) {
}
TEST_F(SharedWorkerDevToolsManagerTest, ReattachTest) {
- SharedWorkerInstance instance(GURL("http://example.com/w3.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- partition_id_);
+ SharedWorkerInstance instance(
+ GURL("http://example.com/w3.js"), base::string16(), base::string16(),
+ blink::WebContentSecurityPolicyTypeReport,
+ browser_context_->GetResourceContext(), partition_id_,
+ blink::WebSharedWorkerCreationContextTypeNonsecure);
scoped_ptr<TestDevToolsClientHost> client_host(new TestDevToolsClientHost());
// Created -> GetDevToolsAgentHost -> Register -> Destroyed
manager_->WorkerCreated(3, 1, instance);
diff --git a/content/browser/shared_worker/shared_worker_instance.cc b/content/browser/shared_worker/shared_worker_instance.cc
index ea8e02d..caa3876 100644
--- a/content/browser/shared_worker/shared_worker_instance.cc
+++ b/content/browser/shared_worker/shared_worker_instance.cc
@@ -14,13 +14,15 @@ SharedWorkerInstance::SharedWorkerInstance(
const base::string16& content_security_policy,
blink::WebContentSecurityPolicyType security_policy_type,
ResourceContext* resource_context,
- const WorkerStoragePartitionId& partition_id)
+ const WorkerStoragePartitionId& partition_id,
+ blink::WebSharedWorkerCreationContextType creation_context_type)
: url_(url),
name_(name),
content_security_policy_(content_security_policy),
security_policy_type_(security_policy_type),
resource_context_(resource_context),
- partition_id_(partition_id) {
+ partition_id_(partition_id),
+ creation_context_type_(creation_context_type) {
DCHECK(resource_context_);
}
@@ -30,8 +32,8 @@ SharedWorkerInstance::SharedWorkerInstance(const SharedWorkerInstance& other)
content_security_policy_(other.content_security_policy_),
security_policy_type_(other.security_policy_type_),
resource_context_(other.resource_context_),
- partition_id_(other.partition_id_) {
-}
+ partition_id_(other.partition_id_),
+ creation_context_type_(other.creation_context_type_) {}
SharedWorkerInstance::~SharedWorkerInstance() {}
diff --git a/content/browser/shared_worker/shared_worker_instance.h b/content/browser/shared_worker/shared_worker_instance.h
index 5d650e5..f3b3be6 100644
--- a/content/browser/shared_worker/shared_worker_instance.h
+++ b/content/browser/shared_worker/shared_worker_instance.h
@@ -11,6 +11,7 @@
#include "content/browser/shared_worker/worker_storage_partition.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/public/web/WebContentSecurityPolicy.h"
+#include "third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h"
#include "url/gurl.h"
namespace content {
@@ -20,12 +21,14 @@ class ResourceContext;
// the UI thread and be used for comparison in SharedWorkerDevToolsManager.
class CONTENT_EXPORT SharedWorkerInstance {
public:
- SharedWorkerInstance(const GURL& url,
- const base::string16& name,
- const base::string16& content_security_policy,
- blink::WebContentSecurityPolicyType security_policy_type,
- ResourceContext* resource_context,
- const WorkerStoragePartitionId& partition_id);
+ SharedWorkerInstance(
+ const GURL& url,
+ const base::string16& name,
+ const base::string16& content_security_policy,
+ blink::WebContentSecurityPolicyType security_policy_type,
+ ResourceContext* resource_context,
+ const WorkerStoragePartitionId& partition_id,
+ blink::WebSharedWorkerCreationContextType creation_context_type);
SharedWorkerInstance(const SharedWorkerInstance& other);
~SharedWorkerInstance();
@@ -54,6 +57,9 @@ class CONTENT_EXPORT SharedWorkerInstance {
return resource_context_;
}
const WorkerStoragePartitionId& partition_id() const { return partition_id_; }
+ blink::WebSharedWorkerCreationContextType creation_context_type() const {
+ return creation_context_type_;
+ }
private:
const GURL url_;
@@ -62,6 +68,7 @@ class CONTENT_EXPORT SharedWorkerInstance {
const blink::WebContentSecurityPolicyType security_policy_type_;
ResourceContext* const resource_context_;
const WorkerStoragePartitionId partition_id_;
+ const blink::WebSharedWorkerCreationContextType creation_context_type_;
};
} // namespace content
diff --git a/content/browser/shared_worker/shared_worker_instance_unittest.cc b/content/browser/shared_worker/shared_worker_instance_unittest.cc
index 7811e77..8991b05 100644
--- a/content/browser/shared_worker/shared_worker_instance_unittest.cc
+++ b/content/browser/shared_worker/shared_worker_instance_unittest.cc
@@ -47,12 +47,11 @@ class SharedWorkerInstanceTest : public testing::Test {
};
TEST_F(SharedWorkerInstanceTest, MatchesTest) {
- SharedWorkerInstance instance1(GURL("http://example.com/w.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- partition_id_);
+ SharedWorkerInstance instance1(
+ GURL("http://example.com/w.js"), base::string16(), base::string16(),
+ blink::WebContentSecurityPolicyTypeReport,
+ browser_context_->GetResourceContext(), partition_id_,
+ blink::WebSharedWorkerCreationContextTypeNonsecure);
EXPECT_TRUE(Matches(instance1, "http://example.com/w.js", ""));
EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", ""));
EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", ""));
@@ -62,12 +61,11 @@ TEST_F(SharedWorkerInstanceTest, MatchesTest) {
EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "name"));
EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "name"));
- SharedWorkerInstance instance2(GURL("http://example.com/w.js"),
- base::ASCIIToUTF16("name"),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- partition_id_);
+ SharedWorkerInstance instance2(
+ GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"),
+ base::string16(), blink::WebContentSecurityPolicyTypeReport,
+ browser_context_->GetResourceContext(), partition_id_,
+ blink::WebSharedWorkerCreationContextTypeNonsecure);
EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", ""));
EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", ""));
EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", ""));
diff --git a/content/browser/shared_worker/shared_worker_service_impl.cc b/content/browser/shared_worker/shared_worker_service_impl.cc
index 4e71bde..91579b4 100644
--- a/content/browser/shared_worker/shared_worker_service_impl.cc
+++ b/content/browser/shared_worker/shared_worker_service_impl.cc
@@ -287,13 +287,10 @@ void SharedWorkerServiceImpl::CreateWorker(
blink::WebWorkerCreationError* creation_error) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
*creation_error = blink::WebWorkerCreationErrorNone;
- scoped_ptr<SharedWorkerInstance> instance(
- new SharedWorkerInstance(params.url,
- params.name,
- params.content_security_policy,
- params.security_policy_type,
- resource_context,
- partition_id));
+ scoped_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance(
+ params.url, params.name, params.content_security_policy,
+ params.security_policy_type, resource_context, partition_id,
+ params.creation_context_type));
scoped_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> request(
new SharedWorkerPendingInstance::SharedWorkerPendingRequest(
filter,
@@ -306,6 +303,11 @@ void SharedWorkerServiceImpl::CreateWorker(
*creation_error = blink::WebWorkerCreationErrorURLMismatch;
return;
}
+ if (params.creation_context_type !=
+ pending->instance()->creation_context_type()) {
+ *creation_error = blink::WebWorkerCreationErrorSecureContextMismatch;
+ return;
+ }
pending->AddRequest(request.Pass());
return;
}
@@ -483,6 +485,12 @@ void SharedWorkerServiceImpl::ReserveRenderProcessToCreateWorker(
*creation_error = blink::WebWorkerCreationErrorURLMismatch;
return;
}
+ if (pending_instance->instance()->creation_context_type() !=
+ host->instance()->creation_context_type()) {
+ if (creation_error)
+ *creation_error = blink::WebWorkerCreationErrorSecureContextMismatch;
+ return;
+ }
worker_process_id = host->process_id();
worker_route_id = host->worker_route_id();
is_new_worker = false;
diff --git a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
index 6fe9757..332490a 100644
--- a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
+++ b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
@@ -251,6 +251,8 @@ void PostCreateWorker(MockRendererProcessHost* renderer,
params.security_policy_type = blink::WebContentSecurityPolicyTypeReport;
params.document_id = document_id;
params.render_frame_route_id = render_frame_route_id;
+ params.creation_context_type =
+ blink::WebSharedWorkerCreationContextTypeSecure;
EXPECT_TRUE(
renderer->OnMessageReceived(new ViewHostMsg_CreateWorker(params, reply)));
}
diff --git a/content/common/DEPS b/content/common/DEPS
index e2d9fd7..a890606f 100644
--- a/content/common/DEPS
+++ b/content/common/DEPS
@@ -57,6 +57,7 @@ include_rules = [
"+third_party/WebKit/public/web/WebPluginAction.h",
"+third_party/WebKit/public/web/WebPopupType.h",
"+third_party/WebKit/public/web/WebSandboxFlags.h",
+ "+third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h",
"+third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h",
"+third_party/WebKit/public/web/WebTextDirection.h",
"+third_party/WebKit/public/web/WebTreeScopeType.h",
diff --git a/content/common/content_param_traits_macros.h b/content/common/content_param_traits_macros.h
index 67d7237..762436d 100644
--- a/content/common/content_param_traits_macros.h
+++ b/content/common/content_param_traits_macros.h
@@ -18,6 +18,7 @@
#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
#include "third_party/WebKit/public/web/WebContentSecurityPolicy.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h"
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
@@ -32,6 +33,8 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::RequestContextFrameType,
content::REQUEST_CONTEXT_FRAME_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContentSecurityPolicyType,
blink::WebContentSecurityPolicyTypeLast)
+IPC_ENUM_TRAITS_MAX_VALUE(blink::WebSharedWorkerCreationContextType,
+ blink::WebSharedWorkerCreationContextTypeLast)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebInputEvent::Type,
blink::WebInputEvent::TypeFirst,
blink::WebInputEvent::TypeLast)
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index e1375a5..a95ad79 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -50,6 +50,7 @@
#include "third_party/WebKit/public/web/WebMediaPlayerAction.h"
#include "third_party/WebKit/public/web/WebPluginAction.h"
#include "third_party/WebKit/public/web/WebPopupType.h"
+#include "third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h"
#include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h"
#include "third_party/WebKit/public/web/WebTextDirection.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -377,6 +378,10 @@ IPC_STRUCT_BEGIN(ViewHostMsg_CreateWorker_Params)
// RenderFrame routing id used to send messages back to the parent.
IPC_STRUCT_MEMBER(int, render_frame_route_id)
+
+ // The type (secure or nonsecure) of the context that created the worker.
+ IPC_STRUCT_MEMBER(blink::WebSharedWorkerCreationContextType,
+ creation_context_type)
IPC_STRUCT_END()
IPC_STRUCT_BEGIN(ViewHostMsg_CreateWorker_Reply)
diff --git a/content/renderer/shared_worker_repository.cc b/content/renderer/shared_worker_repository.cc
index 357cc95..3c1e73c 100644
--- a/content/renderer/shared_worker_repository.cc
+++ b/content/renderer/shared_worker_repository.cc
@@ -27,6 +27,7 @@ SharedWorkerRepository::createSharedWorkerConnector(
DocumentID document_id,
const blink::WebString& content_security_policy,
blink::WebContentSecurityPolicyType security_policy_type,
+ blink::WebSharedWorkerCreationContextType creation_context_type,
blink::WebWorkerCreationError* error) {
ViewHostMsg_CreateWorker_Params params;
params.url = url;
@@ -35,6 +36,7 @@ SharedWorkerRepository::createSharedWorkerConnector(
params.security_policy_type = security_policy_type;
params.document_id = document_id;
params.render_frame_route_id = render_frame()->GetRoutingID();
+ params.creation_context_type = creation_context_type;
ViewHostMsg_CreateWorker_Reply reply;
Send(new ViewHostMsg_CreateWorker(params, &reply));
if (reply.route_id == MSG_ROUTING_NONE) {
diff --git a/content/renderer/shared_worker_repository.h b/content/renderer/shared_worker_repository.h
index 004398d..c245fec 100644
--- a/content/renderer/shared_worker_repository.h
+++ b/content/renderer/shared_worker_repository.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "content/public/renderer/render_frame_observer.h"
#include "third_party/WebKit/public/web/WebContentSecurityPolicy.h"
+#include "third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h"
#include "third_party/WebKit/public/web/WebSharedWorkerRepositoryClient.h"
namespace content {
@@ -29,6 +30,7 @@ class SharedWorkerRepository : public RenderFrameObserver,
DocumentID document_id,
const blink::WebString& content_security_policy,
blink::WebContentSecurityPolicyType,
+ blink::WebSharedWorkerCreationContextType,
blink::WebWorkerCreationError* error) override;
void documentDetached(DocumentID document_id) override;
diff --git a/third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker-in-iframe.html b/third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker-in-iframe.html
new file mode 100644
index 0000000..8f0d8c7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker-in-iframe.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ // get-host-info.js, loaded below, is considered active mixed
+ // content when this page is loaded over HTTP in an iframe inside an
+ // HTTPS page. Allow active mixed content here so that
+ // get-host-info.js runs.
+ if (window.testRunner) {
+ testRunner.overridePreference("WebKitAllowRunningInsecureContent", true);
+ testRunner.setAllowRunningOfInsecureContent(true);
+ }
+ </script>
+
+ <script src="/resources/get-host-info.js"></script>
+ <script>
+ window.onmessage = function (event) {
+ window.parent.postMessage(event.data, "*");
+ }
+
+ window.onload = function () {
+ var iframe = document.createElement("iframe");
+ iframe.src = get_host_info().HTTPS_ORIGIN + "/workers/resources/load-worker.html";
+ document.body.appendChild(iframe);
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker.html b/third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker.html
new file mode 100644
index 0000000..ecc53e1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/workers/resources/load-worker.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="/resources/get-host-info.js"></script>
+ <script>
+ try {
+ var worker = new SharedWorker(get_host_info().HTTPS_ORIGIN + "/workers/resources/worker-util.js", "worker");
+ } catch (e) {
+ window.parent.postMessage({ error: e.toString() }, "*");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/http/tests/workers/shared-worker-secure-context.https.html b/third_party/WebKit/LayoutTests/http/tests/workers/shared-worker-secure-context.https.html
new file mode 100644
index 0000000..d5c9055
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/workers/shared-worker-secure-context.https.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/resources/get-host-info.js"></script>
+</head>
+<body>
+</body>
+<script>
+ if (window.testRunner) {
+ testRunner.setAllowRunningOfInsecureContent(true);
+ }
+
+ window.onload = function() {
+ var test = async_test("Shared workers secure context");
+
+ window.onmessage = test.step_func(function (event) {
+ assert_equals("SecurityError: Failed to construct 'SharedWorker': The SharedWorker named 'worker' was created from a secure context and this context is not secure.", event.data.error);
+ test.done();
+ });
+
+ test.step(function () {
+ var worker = new SharedWorker("resources/worker-util.js", "worker");
+ var iframe = document.createElement("iframe");
+ iframe.src = get_host_info().UNAUTHENTICATED_ORIGIN + "/workers/resources/load-worker-in-iframe.html";
+ document.body.appendChild(iframe);
+ });
+ };
+</script>
+</html>
diff --git a/third_party/WebKit/Source/web/SharedWorkerRepositoryClientImpl.cpp b/third_party/WebKit/Source/web/SharedWorkerRepositoryClientImpl.cpp
index 1141c3a..b782192 100644
--- a/third_party/WebKit/Source/web/SharedWorkerRepositoryClientImpl.cpp
+++ b/third_party/WebKit/Source/web/SharedWorkerRepositoryClientImpl.cpp
@@ -130,13 +130,20 @@ void SharedWorkerRepositoryClientImpl::connect(SharedWorker* worker, PassOwnPtr<
}
WebWorkerCreationError creationError;
- OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->createSharedWorkerConnector(url, name, getId(document), header, headerType, &creationError));
+ String unusedSecureContextError;
+ bool isSecureContext = worker->executionContext()->isSecureContext(unusedSecureContextError);
+ OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->createSharedWorkerConnector(url, name, getId(document), header, headerType, isSecureContext ? WebSharedWorkerCreationContextTypeSecure : WebSharedWorkerCreationContextTypeNonsecure, &creationError));
if (!webWorkerConnector) {
- // TODO(estark): This assertion will shortly go away and each
- // different error type will be handled. https://crbug.com/561216
- ASSERT(creationError == WebWorkerCreationErrorURLMismatch);
- // Existing worker does not match this url, so return an error back to the caller.
- exceptionState.throwDOMException(URLMismatchError, "The location of the SharedWorker named '" + name + "' does not exactly match the provided URL ('" + url.elidedString() + "').");
+ if (creationError == WebWorkerCreationErrorURLMismatch) {
+ // Existing worker does not match this url, so return an error back to the caller.
+ exceptionState.throwDOMException(URLMismatchError, "The location of the SharedWorker named '" + name + "' does not exactly match the provided URL ('" + url.elidedString() + "').");
+ } else if (creationError == WebWorkerCreationErrorSecureContextMismatch) {
+ if (isSecureContext) {
+ exceptionState.throwSecurityError("The SharedWorker named '" + name + "' was created from a nonsecure context and this context is secure.");
+ } else {
+ exceptionState.throwSecurityError("The SharedWorker named '" + name + "' was created from a secure context and this context is not secure.");
+ }
+ }
return;
}
diff --git a/third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h b/third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h
new file mode 100644
index 0000000..858a200
--- /dev/null
+++ b/third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h
@@ -0,0 +1,23 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be found
+// in the LICENSE file.
+
+#ifndef WebSharedWorkerCreationContextType_h
+#define WebSharedWorkerCreationContextType_h
+
+#include "../platform/WebCommon.h"
+
+namespace blink {
+
+// Describes the type of context (secure or non-secure) that created a SharedWorker.
+enum WebSharedWorkerCreationContextType {
+ // The shared worker was created from a nonsecure context.
+ WebSharedWorkerCreationContextTypeNonsecure = 0,
+ // The shared worker was created from a secure context.
+ WebSharedWorkerCreationContextTypeSecure,
+ WebSharedWorkerCreationContextTypeLast = WebSharedWorkerCreationContextTypeSecure
+};
+
+} // namespace blink
+
+#endif // WebSharedWorkerCreationContextType_h
diff --git a/third_party/WebKit/public/web/WebSharedWorkerRepositoryClient.h b/third_party/WebKit/public/web/WebSharedWorkerRepositoryClient.h
index 119d63a..6f76261 100644
--- a/third_party/WebKit/public/web/WebSharedWorkerRepositoryClient.h
+++ b/third_party/WebKit/public/web/WebSharedWorkerRepositoryClient.h
@@ -32,6 +32,7 @@
#define WebSharedWorkerRepositoryClient_h
#include "WebSharedWorkerConnector.h"
+#include "WebSharedWorkerCreationContextType.h"
#include "WebSharedWorkerCreationErrors.h"
namespace blink {
@@ -46,7 +47,7 @@ public:
typedef unsigned long long DocumentID;
// Creates a new shared worker connector. This may return null.
- virtual WebSharedWorkerConnector* createSharedWorkerConnector(const WebURL& url, const WebString& name, DocumentID id, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType, WebWorkerCreationError* error) { return 0; }
+ virtual WebSharedWorkerConnector* createSharedWorkerConnector(const WebURL& url, const WebString& name, DocumentID id, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType, WebSharedWorkerCreationContextType, WebWorkerCreationError* error) { return 0; }
// Invoked when a document has been detached. DocumentID can be re-used after documentDetached() is invoked.
virtual void documentDetached(DocumentID) { }