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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_host_unittest.cc

Issue 325173002: ServiceWorker: Confirm the liveness of the associated context before handling message (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
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 1eaeadbcdcfcc3bb65b26cf6d88e0e647c99cd2b..b267fcde37424470c4778635d5eff404e3475a80 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -13,6 +13,7 @@
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
+#include "content/browser/service_worker/service_worker_provider_host_registry.h"
#include "content/common/service_worker/embedded_worker_messages.h"
#include "content/common/service_worker/service_worker_messages.h"
#include "content/public/common/content_switches.h"
@@ -36,11 +37,14 @@ class ServiceWorkerDispatcherHostTest : public testing::Test {
helper_.reset();
}
- ServiceWorkerContextCore* context() { return helper_->context(); }
ServiceWorkerContextWrapper* context_wrapper() {
return helper_->context_wrapper();
}
+ ServiceWorkerProviderHostRegistry* provider_registry() {
+ return context_wrapper()->provider_registry();
+ }
+
TestBrowserThreadBundle browser_thread_bundle_;
scoped_ptr<EmbeddedWorkerTestHelper> helper_;
};
@@ -152,7 +156,8 @@ TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) {
dispatcher_host->OnMessageReceived(
ServiceWorkerHostMsg_ProviderCreated(kProviderId));
- EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId));
+ EXPECT_TRUE(provider_registry()->GetProviderHost(kRenderProcessId,
+ kProviderId));
// Two with the same ID should be seen as a bad message.
dispatcher_host->OnMessageReceived(
@@ -161,7 +166,8 @@ TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) {
dispatcher_host->OnMessageReceived(
ServiceWorkerHostMsg_ProviderDestroyed(kProviderId));
- EXPECT_FALSE(context()->GetProviderHost(kRenderProcessId, kProviderId));
+ EXPECT_FALSE(provider_registry()->GetProviderHost(kRenderProcessId,
+ kProviderId));
// Destroying an ID that does not exist warrants a bad message.
dispatcher_host->OnMessageReceived(
@@ -172,10 +178,12 @@ TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) {
// process to get deleted as well.
dispatcher_host->OnMessageReceived(
ServiceWorkerHostMsg_ProviderCreated(kProviderId));
- EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId));
+ EXPECT_TRUE(provider_registry()->GetProviderHost(kRenderProcessId,
+ kProviderId));
EXPECT_TRUE(dispatcher_host->HasOneRef());
dispatcher_host = NULL;
- EXPECT_FALSE(context()->GetProviderHost(kRenderProcessId, kProviderId));
+ EXPECT_FALSE(provider_registry()->GetProviderHost(kRenderProcessId,
+ kProviderId));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698