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

Unified 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: comment and move expect 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/service_worker/embedded_worker_registry.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
index 1dc9254d50c2e163be4e2f992b06a9322816be68..1880575965197621b398ccc768b7a64f460ac79b 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -23,6 +23,7 @@
#include "content/browser/service_worker/service_worker_handle.h"
#include "content/common/service_worker/embedded_worker_messages.h"
#include "content/common/service_worker/service_worker_messages.h"
+#include "content/common/service_worker/service_worker_utils.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/mock_resource_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -769,4 +770,30 @@ TEST_F(ServiceWorkerDispatcherHostTest, OnSetHostedVersionId) {
ServiceWorkerMsg_AssociateRegistration::ID));
}
+TEST_F(ServiceWorkerDispatcherHostTest, ReceivedTimedOutRequestResponse) {
+ GURL pattern = GURL("https://www.example.com/");
+ GURL script_url = GURL("https://www.example.com/service_worker.js");
+
+ SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_WINDOW, pattern);
+ SetUpRegistration(pattern, script_url);
+
+ version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
+ base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
+ base::RunLoop().RunUntilIdle();
+
+ // Set the worker status to STOPPING.
+ version_->embedded_worker()->Stop();
+ EXPECT_EQ(EmbeddedWorkerStatus::STOPPING, version_->running_status());
+
+ // Receive a response for a timed out request. The bad message count should
+ // not increase.
+ const int kRequestId = 91; // Dummy value
+ dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse(
+ version_->embedded_worker()->embedded_worker_id(), kRequestId,
+ SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse()));
+
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_);
+}
+
} // namespace content
« 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