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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host_unittest.cc

Issue 2150863002: service worker: Don't BadMessageReceived when a response for a timed out request arrives (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « content/browser/service_worker/embedded_worker_registry.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "content/browser/browser_thread_impl.h" 15 #include "content/browser/browser_thread_impl.h"
16 #include "content/browser/message_port_service.h" 16 #include "content/browser/message_port_service.h"
17 #include "content/browser/service_worker/embedded_worker_instance.h" 17 #include "content/browser/service_worker/embedded_worker_instance.h"
18 #include "content/browser/service_worker/embedded_worker_registry.h" 18 #include "content/browser/service_worker/embedded_worker_registry.h"
19 #include "content/browser/service_worker/embedded_worker_status.h" 19 #include "content/browser/service_worker/embedded_worker_status.h"
20 #include "content/browser/service_worker/embedded_worker_test_helper.h" 20 #include "content/browser/service_worker/embedded_worker_test_helper.h"
21 #include "content/browser/service_worker/service_worker_context_core.h" 21 #include "content/browser/service_worker/service_worker_context_core.h"
22 #include "content/browser/service_worker/service_worker_context_wrapper.h" 22 #include "content/browser/service_worker/service_worker_context_wrapper.h"
23 #include "content/browser/service_worker/service_worker_handle.h" 23 #include "content/browser/service_worker/service_worker_handle.h"
24 #include "content/common/service_worker/embedded_worker_messages.h" 24 #include "content/common/service_worker/embedded_worker_messages.h"
25 #include "content/common/service_worker/service_worker_messages.h" 25 #include "content/common/service_worker/service_worker_messages.h"
26 #include "content/common/service_worker/service_worker_utils.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
27 #include "content/public/test/mock_resource_context.h" 28 #include "content/public/test/mock_resource_context.h"
28 #include "content/public/test/test_browser_thread_bundle.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
29 #include "content/test/test_content_browser_client.h" 30 #include "content/test/test_content_browser_client.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 32
32 namespace content { 33 namespace content {
33 34
34 namespace { 35 namespace {
35 36
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 EXPECT_NE(version_->embedded_worker()->process_id(), 763 EXPECT_NE(version_->embedded_worker()->process_id(),
763 provider_host_->process_id()); 764 provider_host_->process_id());
764 // SendSetHostedVersionId should reject because the provider host process id 765 // SendSetHostedVersionId should reject because the provider host process id
765 // is different. 766 // is different.
766 SendSetHostedVersionId(kProviderId, version_->version_id()); 767 SendSetHostedVersionId(kProviderId, version_->version_id());
767 base::RunLoop().RunUntilIdle(); 768 base::RunLoop().RunUntilIdle();
768 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( 769 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching(
769 ServiceWorkerMsg_AssociateRegistration::ID)); 770 ServiceWorkerMsg_AssociateRegistration::ID));
770 } 771 }
771 772
773 TEST_F(ServiceWorkerDispatcherHostTest, ReceivedTimedOutRequestResponse) {
774 GURL pattern = GURL("https://www.example.com/");
775 GURL script_url = GURL("https://www.example.com/service_worker.js");
776
777 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_WINDOW, pattern);
778 SetUpRegistration(pattern, script_url);
779
780 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
781 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
782 base::RunLoop().RunUntilIdle();
783
784 // Set the worker status to STOPPING.
785 version_->embedded_worker()->Stop();
786 EXPECT_EQ(EmbeddedWorkerStatus::STOPPING, version_->running_status());
787
788 // Receive a response for a timed out request. The bad
789 // message count should not increase.
nhiroki 2016/07/14 10:35:27 nit: a position of starting a new line looks odd.
falken 2016/07/14 11:05:28 Done.
790 const int kRequestId = 91; // Dummy value
791 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse(
792 version_->embedded_worker()->embedded_worker_id(), kRequestId,
793 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse()));
794 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_);
falken 2016/07/14 11:05:28 I also realized this should move after RunUntilIdl
795
796 base::RunLoop().RunUntilIdle();
797 }
798
772 } // namespace content 799 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/embedded_worker_registry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698