OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 version_id = infos[index].active_version.version_id; | 329 version_id = infos[index].active_version.version_id; |
330 else | 330 else |
331 return; | 331 return; |
332 | 332 |
333 ServiceWorkerVersion* version = wrapper->GetLiveVersion(version_id); | 333 ServiceWorkerVersion* version = wrapper->GetLiveVersion(version_id); |
334 *num_resources = static_cast<int>(version->script_cache_map()->size()); | 334 *num_resources = static_cast<int>(version->script_cache_map()->size()); |
335 } | 335 } |
336 | 336 |
337 } // namespace | 337 } // namespace |
338 | 338 |
339 class ServiceWorkerBrowserTest | 339 class ServiceWorkerBrowserTest : public testing::WithParamInterface<bool>, |
340 : public MojoServiceWorkerTestP<ContentBrowserTest> { | 340 public ContentBrowserTest { |
341 protected: | 341 protected: |
342 using self = ServiceWorkerBrowserTest; | 342 using self = ServiceWorkerBrowserTest; |
343 | 343 |
| 344 void SetUp() override { |
| 345 is_mojo_enabled_ = GetParam(); |
| 346 if (is_mojo_enabled()) { |
| 347 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 348 switches::kMojoServiceWorker); |
| 349 } |
| 350 ContentBrowserTest::SetUp(); |
| 351 } |
| 352 |
344 void SetUpOnMainThread() override { | 353 void SetUpOnMainThread() override { |
345 ASSERT_TRUE(embedded_test_server()->Start()); | 354 ASSERT_TRUE(embedded_test_server()->Start()); |
346 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition( | 355 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition( |
347 shell()->web_contents()->GetBrowserContext()); | 356 shell()->web_contents()->GetBrowserContext()); |
348 wrapper_ = static_cast<ServiceWorkerContextWrapper*>( | 357 wrapper_ = static_cast<ServiceWorkerContextWrapper*>( |
349 partition->GetServiceWorkerContext()); | 358 partition->GetServiceWorkerContext()); |
350 | 359 |
351 // Navigate to the page to set up a renderer page (where we can embed | 360 // Navigate to the page to set up a renderer page (where we can embed |
352 // a worker). | 361 // a worker). |
353 NavigateToURLBlockUntilNavigationsComplete( | 362 NavigateToURLBlockUntilNavigationsComplete( |
354 shell(), | 363 shell(), |
355 embedded_test_server()->GetURL("/service_worker/empty.html"), 1); | 364 embedded_test_server()->GetURL("/service_worker/empty.html"), 1); |
356 | 365 |
357 RunOnIOThread(base::Bind(&self::SetUpOnIOThread, base::Unretained(this))); | 366 RunOnIOThread(base::Bind(&self::SetUpOnIOThread, base::Unretained(this))); |
358 } | 367 } |
359 | 368 |
360 void TearDownOnMainThread() override { | 369 void TearDownOnMainThread() override { |
361 RunOnIOThread( | 370 RunOnIOThread( |
362 base::Bind(&self::TearDownOnIOThread, base::Unretained(this))); | 371 base::Bind(&self::TearDownOnIOThread, base::Unretained(this))); |
363 wrapper_ = NULL; | 372 wrapper_ = NULL; |
364 } | 373 } |
365 | 374 |
366 virtual void SetUpOnIOThread() {} | 375 virtual void SetUpOnIOThread() {} |
367 virtual void TearDownOnIOThread() {} | 376 virtual void TearDownOnIOThread() {} |
368 | 377 |
369 ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); } | 378 ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); } |
370 ServiceWorkerContext* public_context() { return wrapper(); } | 379 ServiceWorkerContext* public_context() { return wrapper(); } |
| 380 bool is_mojo_enabled() const { return is_mojo_enabled_; } |
371 | 381 |
372 void AssociateRendererProcessToPattern(const GURL& pattern) { | 382 void AssociateRendererProcessToPattern(const GURL& pattern) { |
373 wrapper_->process_manager()->AddProcessReferenceToPattern( | 383 wrapper_->process_manager()->AddProcessReferenceToPattern( |
374 pattern, shell()->web_contents()->GetRenderProcessHost()->GetID()); | 384 pattern, shell()->web_contents()->GetRenderProcessHost()->GetID()); |
375 } | 385 } |
376 | 386 |
377 private: | 387 private: |
378 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; | 388 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; |
| 389 bool is_mojo_enabled_ = false; |
379 }; | 390 }; |
380 | 391 |
381 class ConsoleListener : public EmbeddedWorkerInstance::Listener { | 392 class ConsoleListener : public EmbeddedWorkerInstance::Listener { |
382 public: | 393 public: |
383 void OnReportConsoleMessage(int source_identifier, | 394 void OnReportConsoleMessage(int source_identifier, |
384 int message_level, | 395 int message_level, |
385 const base::string16& message, | 396 const base::string16& message, |
386 int line_number, | 397 int line_number, |
387 const GURL& source_url) override { | 398 const GURL& source_url) override { |
388 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 399 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 ServiceWorkerV8CacheStrategiesNormalTest, | 2068 ServiceWorkerV8CacheStrategiesNormalTest, |
2058 ::testing::Values(true, false)); | 2069 ::testing::Values(true, false)); |
2059 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, | 2070 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, |
2060 ServiceWorkerV8CacheStrategiesAggressiveTest, | 2071 ServiceWorkerV8CacheStrategiesAggressiveTest, |
2061 ::testing::Values(true, false)); | 2072 ::testing::Values(true, false)); |
2062 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, | 2073 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, |
2063 ServiceWorkerDisableWebSecurityTest, | 2074 ServiceWorkerDisableWebSecurityTest, |
2064 ::testing::Values(true, false)); | 2075 ::testing::Values(true, false)); |
2065 | 2076 |
2066 } // namespace content | 2077 } // namespace content |
OLD | NEW |