| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "content/browser/service_worker/embedded_worker_instance.h" | 9 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 10 #include "content/browser/service_worker/embedded_worker_registry.h" | 10 #include "content/browser/service_worker/embedded_worker_registry.h" |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 }; | 584 }; |
| 585 | 585 |
| 586 IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) { | 586 IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) { |
| 587 const std::string kWorkerUrl = "/service_worker/fetch_event.js"; | 587 const std::string kWorkerUrl = "/service_worker/fetch_event.js"; |
| 588 | 588 |
| 589 // Unregistering nothing should return true. | 589 // Unregistering nothing should return true. |
| 590 { | 590 { |
| 591 base::RunLoop run_loop; | 591 base::RunLoop run_loop; |
| 592 public_context()->UnregisterServiceWorker( | 592 public_context()->UnregisterServiceWorker( |
| 593 embedded_test_server()->GetURL("/*"), | 593 embedded_test_server()->GetURL("/*"), |
| 594 RenderProcessID(), | |
| 595 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, | 594 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, |
| 596 true, | 595 true, |
| 597 run_loop.QuitClosure())); | 596 run_loop.QuitClosure())); |
| 598 run_loop.Run(); | 597 run_loop.Run(); |
| 599 } | 598 } |
| 600 | 599 |
| 601 // Register returns when the promise would be resolved. | 600 // Register returns when the promise would be resolved. |
| 602 { | 601 { |
| 603 base::RunLoop run_loop; | 602 base::RunLoop run_loop; |
| 604 public_context()->RegisterServiceWorker( | 603 public_context()->RegisterServiceWorker( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 625 | 624 |
| 626 // The registration algo might not be far enough along to have | 625 // The registration algo might not be far enough along to have |
| 627 // stored the registration data, so it may not be findable | 626 // stored the registration data, so it may not be findable |
| 628 // at this point. | 627 // at this point. |
| 629 | 628 |
| 630 // Unregistering something should return true. | 629 // Unregistering something should return true. |
| 631 { | 630 { |
| 632 base::RunLoop run_loop; | 631 base::RunLoop run_loop; |
| 633 public_context()->UnregisterServiceWorker( | 632 public_context()->UnregisterServiceWorker( |
| 634 embedded_test_server()->GetURL("/*"), | 633 embedded_test_server()->GetURL("/*"), |
| 635 RenderProcessID(), | |
| 636 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, | 634 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, |
| 637 true, | 635 true, |
| 638 run_loop.QuitClosure())); | 636 run_loop.QuitClosure())); |
| 639 run_loop.Run(); | 637 run_loop.Run(); |
| 640 } | 638 } |
| 641 | 639 |
| 642 // Should not be able to find it. | 640 // Should not be able to find it. |
| 643 { | 641 { |
| 644 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 642 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 645 GURL script_url; | 643 GURL script_url; |
| 646 RunOnIOThread( | 644 RunOnIOThread( |
| 647 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, | 645 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, |
| 648 this, | 646 this, |
| 649 embedded_test_server()->GetURL("/service_worker/empty.html"), | 647 embedded_test_server()->GetURL("/service_worker/empty.html"), |
| 650 &status, | 648 &status, |
| 651 &script_url)); | 649 &script_url)); |
| 652 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); | 650 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); |
| 653 } | 651 } |
| 654 } | 652 } |
| 655 | 653 |
| 656 } // namespace content | 654 } // namespace content |
| OLD | NEW |