| Index: content/browser/shared_worker/shared_worker_service_impl_unittest.cc
|
| 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 b1b809a54586840c2f2eb20559218aa82df18558..97edf365e4eb26a621ef0bada8ef073312572a1d 100644
|
| --- a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
|
| +++ b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
|
| @@ -33,6 +33,18 @@
|
|
|
| namespace content {
|
|
|
| +namespace {
|
| +
|
| +void CreateWorkerCallback(int* route_id_out,
|
| + blink::WebWorkerCreationError* creation_error_out,
|
| + int route_id,
|
| + blink::WebWorkerCreationError creation_error) {
|
| + *route_id_out = route_id;
|
| + *creation_error_out = creation_error;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| class SharedWorkerServiceImplTest : public testing::Test {
|
| public:
|
| static void RegisterRunningProcessID(int process_id) {
|
| @@ -211,6 +223,19 @@ class MockRendererProcessHost {
|
| return ret;
|
| }
|
|
|
| + // Emulates mojo RPC calls (Renderer(Document)->Browser).
|
| + void OnCreateWorker(mojom::SharedWorkerCreateParamsPtr params,
|
| + int* route_id_out,
|
| + blink::WebWorkerCreationError* creation_error_out) {
|
| + worker_filter_->OnCreateWorker(
|
| + std::move(params),
|
| + base::Bind(&CreateWorkerCallback, route_id_out, creation_error_out));
|
| + }
|
| +
|
| + void OnConnectToWorker(int route_id, int message_port_id) {
|
| + worker_filter_->OnConnectToWorker(route_id, message_port_id);
|
| + }
|
| +
|
| size_t QueuedMessageCount() const { return queued_messages_.size(); }
|
|
|
| std::unique_ptr<IPC::Message> PopMessage() {
|
| @@ -252,18 +277,19 @@ void PostCreateWorker(MockRendererProcessHost* renderer,
|
| const std::string& name,
|
| unsigned long long document_id,
|
| int render_frame_route_id,
|
| - ViewHostMsg_CreateWorker_Reply* reply) {
|
| - ViewHostMsg_CreateWorker_Params params;
|
| - params.url = GURL(url);
|
| - params.name = base::ASCIIToUTF16(name);
|
| - params.content_security_policy = base::string16();
|
| - params.security_policy_type = blink::WebContentSecurityPolicyTypeReport;
|
| - params.document_id = document_id;
|
| - params.render_frame_route_id = render_frame_route_id;
|
| - params.creation_context_type =
|
| + int* route_id_out,
|
| + blink::WebWorkerCreationError* creation_error_out) {
|
| + mojom::SharedWorkerCreateParamsPtr params =
|
| + mojom::SharedWorkerCreateParams::New();
|
| + params->url = GURL(url);
|
| + params->name = base::ASCIIToUTF16(name);
|
| + params->content_security_policy = base::string16();
|
| + 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)));
|
| + renderer->OnCreateWorker(std::move(params), route_id_out, creation_error_out);
|
| }
|
|
|
| class MockSharedWorkerConnector {
|
| @@ -284,7 +310,7 @@ class MockSharedWorkerConnector {
|
| &local_port_route_id_,
|
| &local_port_id_);
|
| PostCreateWorker(renderer_host_, url, name, document_id,
|
| - render_frame_route_id, &create_worker_reply_);
|
| + render_frame_route_id, &route_id_, &creation_error_);
|
| }
|
| void SendQueueMessages() {
|
| EXPECT_TRUE(renderer_host_->OnMessageReceived(
|
| @@ -297,9 +323,7 @@ class MockSharedWorkerConnector {
|
| local_port_id_, base::ASCIIToUTF16(data), empty_ports)));
|
| }
|
| void SendConnect() {
|
| - EXPECT_TRUE(
|
| - renderer_host_->OnMessageReceived(new ViewHostMsg_ConnectToWorker(
|
| - create_worker_reply_.route_id, remote_port_id_)));
|
| + renderer_host_->OnConnectToWorker(route_id_, remote_port_id_);
|
| }
|
| void SendSendQueuedMessages(
|
| const std::vector<QueuedMessage>& queued_messages) {
|
| @@ -313,10 +337,8 @@ class MockSharedWorkerConnector {
|
| int remote_port_id() { return remote_port_id_; }
|
| int local_port_route_id() { return local_port_route_id_; }
|
| int local_port_id() { return local_port_id_; }
|
| - int route_id() { return create_worker_reply_.route_id; }
|
| - blink::WebWorkerCreationError creation_error() {
|
| - return create_worker_reply_.error;
|
| - }
|
| + int route_id() { return route_id_; }
|
| + blink::WebWorkerCreationError creation_error() { return creation_error_; }
|
|
|
| private:
|
| MockRendererProcessHost* renderer_host_;
|
| @@ -324,7 +346,8 @@ class MockSharedWorkerConnector {
|
| int remote_port_id_;
|
| int local_port_route_id_;
|
| int local_port_id_;
|
| - ViewHostMsg_CreateWorker_Reply create_worker_reply_;
|
| + int route_id_;
|
| + blink::WebWorkerCreationError creation_error_;
|
| };
|
|
|
| void CheckWorkerProcessMsgCreateWorker(
|
|
|