| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, NotificationAPI) { | 586 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, NotificationAPI) { |
| 587 EXPECT_TRUE(RunExtensionSubtest("service_worker/notifications/has_permission", | 587 EXPECT_TRUE(RunExtensionSubtest("service_worker/notifications/has_permission", |
| 588 "page.html")); | 588 "page.html")); |
| 589 } | 589 } |
| 590 | 590 |
| 591 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesFetch) { | 591 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesFetch) { |
| 592 EXPECT_TRUE(RunExtensionSubtest( | 592 EXPECT_TRUE(RunExtensionSubtest( |
| 593 "service_worker/web_accessible_resources/fetch/", "page.html")); | 593 "service_worker/web_accessible_resources/fetch/", "page.html")); |
| 594 } | 594 } |
| 595 | 595 |
| 596 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, TabsCreate) { |
| 597 // Extensions APIs from SW are only enabled on trunk. |
| 598 ScopedCurrentChannel current_channel_override(version_info::Channel::UNKNOWN); |
| 599 const Extension* extension = LoadExtensionWithFlags( |
| 600 test_data_dir_.AppendASCII("service_worker/tabs_create"), kFlagNone); |
| 601 ASSERT_TRUE(extension); |
| 602 ui_test_utils::NavigateToURL(browser(), |
| 603 extension->GetResourceURL("page.html")); |
| 604 content::WebContents* web_contents = |
| 605 browser()->tab_strip_model()->GetActiveWebContents(); |
| 606 |
| 607 int starting_tab_count = browser()->tab_strip_model()->count(); |
| 608 std::string result; |
| 609 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 610 web_contents, "window.runServiceWorker()", &result)); |
| 611 ASSERT_EQ("chrome.tabs.create callback", result); |
| 612 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); |
| 613 |
| 614 // Check extension shutdown path. |
| 615 UnloadExtension(extension->id()); |
| 616 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
| 617 } |
| 618 |
| 596 // This test loads a web page that has an iframe pointing to a | 619 // This test loads a web page that has an iframe pointing to a |
| 597 // chrome-extension:// URL. The URL is listed in the extension's | 620 // chrome-extension:// URL. The URL is listed in the extension's |
| 598 // web_accessible_resources. Initially the iframe is served from the extension's | 621 // web_accessible_resources. Initially the iframe is served from the extension's |
| 599 // resource file. After verifying that, we register a Service Worker that | 622 // resource file. After verifying that, we register a Service Worker that |
| 600 // controls the extension. Further requests to the same resource as before | 623 // controls the extension. Further requests to the same resource as before |
| 601 // should now be served by the Service Worker. | 624 // should now be served by the Service Worker. |
| 602 // This test also verifies that if the requested resource exists in the manifest | 625 // This test also verifies that if the requested resource exists in the manifest |
| 603 // but is not present in the extension directory, the Service Worker can still | 626 // but is not present in the extension directory, the Service Worker can still |
| 604 // serve the resource file. | 627 // serve the resource file. |
| 605 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesIframeSrc) { | 628 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesIframeSrc) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 message.sender_id = "1234567890"; | 754 message.sender_id = "1234567890"; |
| 732 message.raw_data = "testdata"; | 755 message.raw_data = "testdata"; |
| 733 message.decrypted = true; | 756 message.decrypted = true; |
| 734 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 757 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
| 735 push_service()->OnMessage(app_identifier.app_id(), message); | 758 push_service()->OnMessage(app_identifier.app_id(), message); |
| 736 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); | 759 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); |
| 737 run_loop.Run(); // Wait until the message is handled by push service. | 760 run_loop.Run(); // Wait until the message is handled by push service. |
| 738 } | 761 } |
| 739 | 762 |
| 740 } // namespace extensions | 763 } // namespace extensions |
| OLD | NEW |