| 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..9a205c2dae8c163368600b1bb244c978843d4954 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,15 @@
|
|
|
| namespace content {
|
|
|
| +namespace {
|
| +
|
| +void CreateWorkerCallback(mojom::SharedWorker_CreateWorker_ReplyPtr* out,
|
| + mojom::SharedWorker_CreateWorker_ReplyPtr reply) {
|
| + *out = std::move(reply);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| class SharedWorkerServiceImplTest : public testing::Test {
|
| public:
|
| static void RegisterRunningProcessID(int process_id) {
|
| @@ -211,6 +220,17 @@ class MockRendererProcessHost {
|
| return ret;
|
| }
|
|
|
| + // Emulates mojo RPC calls (Renderer(Document)->Browser).
|
| + void OnCreateWorker(mojom::SharedWorker_CreateWorker_ParamsPtr params,
|
| + mojom::SharedWorker_CreateWorker_ReplyPtr* reply) {
|
| + worker_filter_->OnCreateWorker(std::move(params),
|
| + base::Bind(&CreateWorkerCallback, reply));
|
| + }
|
| +
|
| + 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 +272,21 @@ 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 =
|
| - blink::WebSharedWorkerCreationContextTypeSecure;
|
| - EXPECT_TRUE(
|
| - renderer->OnMessageReceived(new ViewHostMsg_CreateWorker(params, reply)));
|
| + mojom::SharedWorker_CreateWorker_ReplyPtr* reply) {
|
| + mojom::SharedWorker_CreateWorker_ParamsPtr params =
|
| + mojom::SharedWorker_CreateWorker_Params::New();
|
| + params->url = GURL(url);
|
| + params->name = base::ASCIIToUTF16(name);
|
| + params->content_security_policy = base::string16();
|
| + params->security_policy_type =
|
| + static_cast<mojom::WebContentSecurityPolicyType>(
|
| + blink::WebContentSecurityPolicyTypeReport);
|
| + params->document_id = document_id;
|
| + params->render_frame_route_id = render_frame_route_id;
|
| + params->creation_context_type =
|
| + static_cast<mojom::WebSharedWorkerCreationContextType>(
|
| + blink::WebSharedWorkerCreationContextTypeSecure);
|
| + renderer->OnCreateWorker(std::move(params), reply);
|
| }
|
|
|
| class MockSharedWorkerConnector {
|
| @@ -297,9 +320,8 @@ 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(create_worker_reply_->route_id,
|
| + remote_port_id_);
|
| }
|
| void SendSendQueuedMessages(
|
| const std::vector<QueuedMessage>& queued_messages) {
|
| @@ -313,9 +335,10 @@ 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; }
|
| + int route_id() { return create_worker_reply_->route_id; }
|
| blink::WebWorkerCreationError creation_error() {
|
| - return create_worker_reply_.error;
|
| + return static_cast<blink::WebWorkerCreationError>(
|
| + create_worker_reply_->error);
|
| }
|
|
|
| private:
|
| @@ -324,7 +347,7 @@ class MockSharedWorkerConnector {
|
| int remote_port_id_;
|
| int local_port_route_id_;
|
| int local_port_id_;
|
| - ViewHostMsg_CreateWorker_Reply create_worker_reply_;
|
| + mojom::SharedWorker_CreateWorker_ReplyPtr create_worker_reply_;
|
| };
|
|
|
| void CheckWorkerProcessMsgCreateWorker(
|
|
|