| Index: content/browser/service_worker/service_worker_provider_host_unittest.cc
|
| diff --git a/content/browser/service_worker/service_worker_provider_host_unittest.cc b/content/browser/service_worker/service_worker_provider_host_unittest.cc
|
| index 91f20b30be77f7e1339432c499ec237c7977d4ee..cdd83782b4a2765dd3c1e5fc2c9d6b2f55cb697c 100644
|
| --- a/content/browser/service_worker/service_worker_provider_host_unittest.cc
|
| +++ b/content/browser/service_worker/service_worker_provider_host_unittest.cc
|
| @@ -151,133 +151,4 @@ TEST_F(ServiceWorkerProviderHostTest,
|
| ASSERT_FALSE(version_->HasProcessToRun());
|
| }
|
|
|
| -class ServiceWorkerProviderHostWaitingVersionTest : public testing::Test {
|
| - protected:
|
| - ServiceWorkerProviderHostWaitingVersionTest()
|
| - : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
|
| - next_provider_id_(1L) {}
|
| - virtual ~ServiceWorkerProviderHostWaitingVersionTest() {}
|
| -
|
| - virtual void SetUp() OVERRIDE {
|
| - context_.reset(
|
| - new ServiceWorkerContextCore(base::FilePath(),
|
| - base::MessageLoopProxy::current(),
|
| - base::MessageLoopProxy::current(),
|
| - NULL,
|
| - NULL,
|
| - NULL));
|
| -
|
| - // Prepare provider hosts (for the same process).
|
| - provider_host1_ = CreateProviderHost(GURL("http://www.example.com/foo"));
|
| - provider_host2_ = CreateProviderHost(GURL("http://www.example.com/bar"));
|
| - provider_host3_ = CreateProviderHost(GURL("http://www.example.ca/foo"));
|
| - }
|
| -
|
| - base::WeakPtr<ServiceWorkerProviderHost> CreateProviderHost(
|
| - const GURL& document_url) {
|
| - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost(
|
| - kRenderProcessId, next_provider_id_++, context_->AsWeakPtr(), NULL));
|
| - host->SetDocumentUrl(document_url);
|
| - base::WeakPtr<ServiceWorkerProviderHost> provider_host = host->AsWeakPtr();
|
| - context_->AddProviderHost(host.Pass());
|
| - return provider_host;
|
| - }
|
| -
|
| - virtual void TearDown() OVERRIDE {
|
| - context_.reset();
|
| - }
|
| -
|
| - content::TestBrowserThreadBundle thread_bundle_;
|
| - scoped_ptr<ServiceWorkerContextCore> context_;
|
| - base::WeakPtr<ServiceWorkerProviderHost> provider_host1_;
|
| - base::WeakPtr<ServiceWorkerProviderHost> provider_host2_;
|
| - base::WeakPtr<ServiceWorkerProviderHost> provider_host3_;
|
| -
|
| - private:
|
| - int64 next_provider_id_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHostWaitingVersionTest);
|
| -};
|
| -
|
| -TEST_F(ServiceWorkerProviderHostWaitingVersionTest,
|
| - AssociateInstallingVersionToDocuments) {
|
| - const GURL scope1("http://www.example.com/*");
|
| - const GURL script_url1("http://www.example.com/service_worker1.js");
|
| - scoped_refptr<ServiceWorkerRegistration> registration1(
|
| - new ServiceWorkerRegistration(
|
| - scope1, script_url1, 1L, context_->AsWeakPtr()));
|
| - scoped_refptr<ServiceWorkerVersion> version1(
|
| - new ServiceWorkerVersion(registration1, 1L, context_->AsWeakPtr()));
|
| -
|
| - ServiceWorkerRegisterJob::AssociateInstallingVersionToDocuments(
|
| - context_->AsWeakPtr(), version1);
|
| - EXPECT_EQ(version1.get(), provider_host1_->installing_version());
|
| - EXPECT_EQ(version1.get(), provider_host2_->installing_version());
|
| - EXPECT_EQ(NULL, provider_host3_->installing_version());
|
| -
|
| - // Version2 is associated with the same registration as version1, so the
|
| - // waiting version of host1 and host2 should be replaced.
|
| - scoped_refptr<ServiceWorkerVersion> version2(
|
| - new ServiceWorkerVersion(registration1, 2L, context_->AsWeakPtr()));
|
| - ServiceWorkerRegisterJob::AssociateInstallingVersionToDocuments(
|
| - context_->AsWeakPtr(), version2);
|
| - EXPECT_EQ(version2.get(), provider_host1_->installing_version());
|
| - EXPECT_EQ(version2.get(), provider_host2_->installing_version());
|
| - EXPECT_EQ(NULL, provider_host3_->installing_version());
|
| -
|
| - const GURL scope3(provider_host1_->document_url());
|
| - const GURL script_url3("http://www.example.com/service_worker3.js");
|
| - scoped_refptr<ServiceWorkerRegistration> registration3(
|
| - new ServiceWorkerRegistration(
|
| - scope3, script_url3, 3L, context_->AsWeakPtr()));
|
| - scoped_refptr<ServiceWorkerVersion> version3(
|
| - new ServiceWorkerVersion(registration3, 3L, context_->AsWeakPtr()));
|
| -
|
| - // Although version3 can match longer than version2 for host1, it should be
|
| - // ignored because version3 is associated with a different registration from
|
| - // version2.
|
| - ServiceWorkerRegisterJob::AssociateInstallingVersionToDocuments(
|
| - context_->AsWeakPtr(), version3);
|
| - EXPECT_EQ(version2.get(), provider_host1_->installing_version());
|
| - EXPECT_EQ(version2.get(), provider_host2_->installing_version());
|
| - EXPECT_EQ(NULL, provider_host3_->installing_version());
|
| -}
|
| -
|
| -TEST_F(ServiceWorkerProviderHostWaitingVersionTest,
|
| - DisassociateVersionFromDocuments) {
|
| - const GURL scope1("http://www.example.com/*");
|
| - const GURL script_url1("http://www.example.com/service_worker.js");
|
| - scoped_refptr<ServiceWorkerRegistration> registration1(
|
| - new ServiceWorkerRegistration(
|
| - scope1, script_url1, 1L, context_->AsWeakPtr()));
|
| - scoped_refptr<ServiceWorkerVersion> version1(
|
| - new ServiceWorkerVersion(registration1, 1L, context_->AsWeakPtr()));
|
| -
|
| - const GURL scope2("http://www.example.ca/*");
|
| - const GURL script_url2("http://www.example.ca/service_worker.js");
|
| - scoped_refptr<ServiceWorkerRegistration> registration2(
|
| - new ServiceWorkerRegistration(
|
| - scope2, script_url2, 2L, context_->AsWeakPtr()));
|
| - scoped_refptr<ServiceWorkerVersion> version2(
|
| - new ServiceWorkerVersion(registration2, 2L, context_->AsWeakPtr()));
|
| -
|
| - ServiceWorkerRegisterJob::AssociateInstallingVersionToDocuments(
|
| - context_->AsWeakPtr(), version1);
|
| - ServiceWorkerRegisterJob::AssociateInstallingVersionToDocuments(
|
| - context_->AsWeakPtr(), version2);
|
| -
|
| - // Host1 and host2 are associated with version1 as a waiting version, whereas
|
| - // host3 is associated with version2.
|
| - EXPECT_EQ(version1.get(), provider_host1_->installing_version());
|
| - EXPECT_EQ(version1.get(), provider_host2_->installing_version());
|
| - EXPECT_EQ(version2.get(), provider_host3_->installing_version());
|
| -
|
| - // Disassociate version1 from host1 and host2.
|
| - ServiceWorkerRegisterJob::DisassociateVersionFromDocuments(
|
| - context_->AsWeakPtr(), version1);
|
| - EXPECT_EQ(NULL, provider_host1_->installing_version());
|
| - EXPECT_EQ(NULL, provider_host2_->installing_version());
|
| - EXPECT_EQ(version2.get(), provider_host3_->installing_version());
|
| -}
|
| -
|
| } // namespace content
|
|
|