| 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 }; | 576 }; |
| 577 | 577 |
| 578 IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) { | 578 IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) { |
| 579 const std::string kWorkerUrl = "/service_worker/fetch_event.js"; | 579 const std::string kWorkerUrl = "/service_worker/fetch_event.js"; |
| 580 | 580 |
| 581 // Unregistering nothing should return true. | 581 // Unregistering nothing should return true. |
| 582 { | 582 { |
| 583 base::RunLoop run_loop; | 583 base::RunLoop run_loop; |
| 584 public_context()->UnregisterServiceWorker( | 584 public_context()->UnregisterServiceWorker( |
| 585 embedded_test_server()->GetURL("/*"), | 585 embedded_test_server()->GetURL("/*"), |
| 586 RenderProcessID(), | |
| 587 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, | 586 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, |
| 588 true, | 587 true, |
| 589 run_loop.QuitClosure())); | 588 run_loop.QuitClosure())); |
| 590 run_loop.Run(); | 589 run_loop.Run(); |
| 591 } | 590 } |
| 592 | 591 |
| 593 // Register returns when the promise would be resolved. | 592 // Register returns when the promise would be resolved. |
| 594 { | 593 { |
| 595 base::RunLoop run_loop; | 594 base::RunLoop run_loop; |
| 596 public_context()->RegisterServiceWorker( | 595 public_context()->RegisterServiceWorker( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 619 | 618 |
| 620 // The registration algo might not be far enough along to have | 619 // The registration algo might not be far enough along to have |
| 621 // stored the registration data, so it may not be findable | 620 // stored the registration data, so it may not be findable |
| 622 // at this point. | 621 // at this point. |
| 623 | 622 |
| 624 // Unregistering something should return true. | 623 // Unregistering something should return true. |
| 625 { | 624 { |
| 626 base::RunLoop run_loop; | 625 base::RunLoop run_loop; |
| 627 public_context()->UnregisterServiceWorker( | 626 public_context()->UnregisterServiceWorker( |
| 628 embedded_test_server()->GetURL("/*"), | 627 embedded_test_server()->GetURL("/*"), |
| 629 RenderProcessID(), | |
| 630 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, | 628 base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun, |
| 631 true, | 629 true, |
| 632 run_loop.QuitClosure())); | 630 run_loop.QuitClosure())); |
| 633 run_loop.Run(); | 631 run_loop.Run(); |
| 634 } | 632 } |
| 635 | 633 |
| 636 // Should not be able to find it. | 634 // Should not be able to find it. |
| 637 { | 635 { |
| 638 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 636 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 639 GURL script_url; | 637 GURL script_url; |
| 640 RunOnIOThread( | 638 RunOnIOThread( |
| 641 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, | 639 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, |
| 642 this, | 640 this, |
| 643 embedded_test_server()->GetURL("/service_worker/empty.html"), | 641 embedded_test_server()->GetURL("/service_worker/empty.html"), |
| 644 &status, | 642 &status, |
| 645 &script_url)); | 643 &script_url)); |
| 646 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); | 644 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); |
| 647 } | 645 } |
| 648 } | 646 } |
| 649 | 647 |
| 650 } // namespace content | 648 } // namespace content |
| OLD | NEW |