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

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

Issue 2477223002: Reland of Use the serviceworker with mojo by default (Closed)
Patch Set: Rebase for navigation-preload Created 4 years, 1 month 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
OLDNEW
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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 std::string value; 378 std::string value;
379 EXPECT_TRUE(name_value_pair->GetString(1, &value)); 379 EXPECT_TRUE(name_value_pair->GetString(1, &value));
380 if (name == header_name && value == header_value) 380 if (name == header_name && value == header_value)
381 return true; 381 return true;
382 } 382 }
383 return false; 383 return false;
384 } 384 }
385 385
386 } // namespace 386 } // namespace
387 387
388 class ServiceWorkerBrowserTest : public testing::WithParamInterface<bool>, 388 class ServiceWorkerBrowserTest
389 public ContentBrowserTest { 389 : public MojoServiceWorkerTestP<ContentBrowserTest> {
390 protected: 390 protected:
391 using self = ServiceWorkerBrowserTest; 391 using self = ServiceWorkerBrowserTest;
392 392
393 void SetUp() override {
394 is_mojo_enabled_ = GetParam();
395 if (is_mojo_enabled()) {
396 base::CommandLine::ForCurrentProcess()->AppendSwitch(
397 switches::kMojoServiceWorker);
398 }
399 ContentBrowserTest::SetUp();
400 }
401
402 void SetUpOnMainThread() override { 393 void SetUpOnMainThread() override {
403 ASSERT_TRUE(embedded_test_server()->Start()); 394 ASSERT_TRUE(embedded_test_server()->Start());
404 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition( 395 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition(
405 shell()->web_contents()->GetBrowserContext()); 396 shell()->web_contents()->GetBrowserContext());
406 wrapper_ = static_cast<ServiceWorkerContextWrapper*>( 397 wrapper_ = static_cast<ServiceWorkerContextWrapper*>(
407 partition->GetServiceWorkerContext()); 398 partition->GetServiceWorkerContext());
408 399
409 // Navigate to the page to set up a renderer page (where we can embed 400 // Navigate to the page to set up a renderer page (where we can embed
410 // a worker). 401 // a worker).
411 NavigateToURLBlockUntilNavigationsComplete( 402 NavigateToURLBlockUntilNavigationsComplete(
412 shell(), 403 shell(),
413 embedded_test_server()->GetURL("/service_worker/empty.html"), 1); 404 embedded_test_server()->GetURL("/service_worker/empty.html"), 1);
414 405
415 RunOnIOThread(base::Bind(&self::SetUpOnIOThread, base::Unretained(this))); 406 RunOnIOThread(base::Bind(&self::SetUpOnIOThread, base::Unretained(this)));
416 } 407 }
417 408
418 void TearDownOnMainThread() override { 409 void TearDownOnMainThread() override {
419 RunOnIOThread( 410 RunOnIOThread(
420 base::Bind(&self::TearDownOnIOThread, base::Unretained(this))); 411 base::Bind(&self::TearDownOnIOThread, base::Unretained(this)));
421 wrapper_ = NULL; 412 wrapper_ = NULL;
422 } 413 }
423 414
424 virtual void SetUpOnIOThread() {} 415 virtual void SetUpOnIOThread() {}
425 virtual void TearDownOnIOThread() {} 416 virtual void TearDownOnIOThread() {}
426 417
427 ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); } 418 ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); }
428 ServiceWorkerContext* public_context() { return wrapper(); } 419 ServiceWorkerContext* public_context() { return wrapper(); }
429 bool is_mojo_enabled() const { return is_mojo_enabled_; }
430 420
431 void AssociateRendererProcessToPattern(const GURL& pattern) { 421 void AssociateRendererProcessToPattern(const GURL& pattern) {
432 wrapper_->process_manager()->AddProcessReferenceToPattern( 422 wrapper_->process_manager()->AddProcessReferenceToPattern(
433 pattern, shell()->web_contents()->GetRenderProcessHost()->GetID()); 423 pattern, shell()->web_contents()->GetRenderProcessHost()->GetID());
434 } 424 }
435 425
436 private: 426 private:
437 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; 427 scoped_refptr<ServiceWorkerContextWrapper> wrapper_;
438 bool is_mojo_enabled_ = false;
439 }; 428 };
440 429
441 class ConsoleListener : public EmbeddedWorkerInstance::Listener { 430 class ConsoleListener : public EmbeddedWorkerInstance::Listener {
442 public: 431 public:
443 void OnReportConsoleMessage(int source_identifier, 432 void OnReportConsoleMessage(int source_identifier,
444 int message_level, 433 int message_level,
445 const base::string16& message, 434 const base::string16& message,
446 int line_number, 435 int line_number,
447 const GURL& source_url) override { 436 const GURL& source_url) override {
448 DCHECK_CURRENTLY_ON(BrowserThread::IO); 437 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2761 ServiceWorkerV8CacheStrategiesNormalTest, 2750 ServiceWorkerV8CacheStrategiesNormalTest,
2762 ::testing::Values(true, false)); 2751 ::testing::Values(true, false));
2763 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 2752 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
2764 ServiceWorkerV8CacheStrategiesAggressiveTest, 2753 ServiceWorkerV8CacheStrategiesAggressiveTest,
2765 ::testing::Values(true, false)); 2754 ::testing::Values(true, false));
2766 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 2755 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
2767 ServiceWorkerDisableWebSecurityTest, 2756 ServiceWorkerDisableWebSecurityTest,
2768 ::testing::Values(true, false)); 2757 ::testing::Values(true, false));
2769 2758
2770 } // namespace content 2759 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698