| 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, NotificationAPI) { | 597 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, NotificationAPI) { |
| 598 EXPECT_TRUE(RunExtensionSubtest("service_worker/notifications/has_permission", | 598 EXPECT_TRUE(RunExtensionSubtest("service_worker/notifications/has_permission", |
| 599 "page.html")); | 599 "page.html")); |
| 600 } | 600 } |
| 601 | 601 |
| 602 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesFetch) { | 602 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesFetch) { |
| 603 EXPECT_TRUE(RunExtensionSubtest( | 603 EXPECT_TRUE(RunExtensionSubtest( |
| 604 "service_worker/web_accessible_resources/fetch/", "page.html")); | 604 "service_worker/web_accessible_resources/fetch/", "page.html")); |
| 605 } | 605 } |
| 606 | 606 |
| 607 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, TabsCreate) { |
| 608 // Extensions APIs from SW are only enabled on trunk. |
| 609 ScopedCurrentChannel current_channel_override(version_info::Channel::UNKNOWN); |
| 610 const Extension* extension = LoadExtensionWithFlags( |
| 611 test_data_dir_.AppendASCII("service_worker/tabs_create"), kFlagNone); |
| 612 ASSERT_TRUE(extension); |
| 613 ui_test_utils::NavigateToURL(browser(), |
| 614 extension->GetResourceURL("page.html")); |
| 615 content::WebContents* web_contents = |
| 616 browser()->tab_strip_model()->GetActiveWebContents(); |
| 617 |
| 618 int starting_tab_count = browser()->tab_strip_model()->count(); |
| 619 std::string result; |
| 620 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 621 web_contents, "window.runServiceWorker()", &result)); |
| 622 ASSERT_EQ("chrome.tabs.create callback", result); |
| 623 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); |
| 624 |
| 625 // Check extension shutdown path. |
| 626 UnloadExtension(extension->id()); |
| 627 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
| 628 } |
| 629 |
| 607 // This test loads a web page that has an iframe pointing to a | 630 // This test loads a web page that has an iframe pointing to a |
| 608 // chrome-extension:// URL. The URL is listed in the extension's | 631 // chrome-extension:// URL. The URL is listed in the extension's |
| 609 // web_accessible_resources. Initially the iframe is served from the extension's | 632 // web_accessible_resources. Initially the iframe is served from the extension's |
| 610 // resource file. After verifying that, we register a Service Worker that | 633 // resource file. After verifying that, we register a Service Worker that |
| 611 // controls the extension. Further requests to the same resource as before | 634 // controls the extension. Further requests to the same resource as before |
| 612 // should now be served by the Service Worker. | 635 // should now be served by the Service Worker. |
| 613 // This test also verifies that if the requested resource exists in the manifest | 636 // This test also verifies that if the requested resource exists in the manifest |
| 614 // but is not present in the extension directory, the Service Worker can still | 637 // but is not present in the extension directory, the Service Worker can still |
| 615 // serve the resource file. | 638 // serve the resource file. |
| 616 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesIframeSrc) { | 639 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesIframeSrc) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 push_message_listener.set_failure_message("FAIL"); | 762 push_message_listener.set_failure_message("FAIL"); |
| 740 gcm::IncomingMessage message; | 763 gcm::IncomingMessage message; |
| 741 message.sender_id = "1234567890"; | 764 message.sender_id = "1234567890"; |
| 742 message.raw_data = "testdata"; | 765 message.raw_data = "testdata"; |
| 743 message.decrypted = true; | 766 message.decrypted = true; |
| 744 push_service()->OnMessage(app_identifier.app_id(), message); | 767 push_service()->OnMessage(app_identifier.app_id(), message); |
| 745 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); | 768 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); |
| 746 } | 769 } |
| 747 | 770 |
| 748 } // namespace extensions | 771 } // namespace extensions |
| OLD | NEW |