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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Sets the channel to "stable". | 195 // Sets the channel to "stable". |
196 // Not useful after we've opened extension Service Workers to stable | 196 // Not useful after we've opened extension Service Workers to stable |
197 // channel. | 197 // channel. |
198 // TODO(lazyboy): Remove this when ExtensionServiceWorkersEnabled() is | 198 // TODO(lazyboy): Remove this when ExtensionServiceWorkersEnabled() is |
199 // removed. | 199 // removed. |
200 ScopedCurrentChannel current_channel_; | 200 ScopedCurrentChannel current_channel_; |
201 | 201 |
202 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerTest); | 202 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerTest); |
203 }; | 203 }; |
204 | 204 |
| 205 class ServiceWorkerPaymentManagerTest : public ServiceWorkerTest { |
| 206 public: |
| 207 ServiceWorkerPaymentManagerTest() {} |
| 208 ~ServiceWorkerPaymentManagerTest() override {} |
| 209 |
| 210 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 211 // ServiceWorkerRegistration.paymentManager requires experimental flag. |
| 212 command_line->AppendSwitch( |
| 213 switches::kEnableExperimentalWebPlatformFeatures); |
| 214 ServiceWorkerTest::SetUpCommandLine(command_line); |
| 215 } |
| 216 |
| 217 private: |
| 218 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerPaymentManagerTest); |
| 219 }; |
| 220 |
205 class ServiceWorkerBackgroundSyncTest : public ServiceWorkerTest { | 221 class ServiceWorkerBackgroundSyncTest : public ServiceWorkerTest { |
206 public: | 222 public: |
207 ServiceWorkerBackgroundSyncTest() {} | 223 ServiceWorkerBackgroundSyncTest() {} |
208 ~ServiceWorkerBackgroundSyncTest() override {} | 224 ~ServiceWorkerBackgroundSyncTest() override {} |
209 | 225 |
210 void SetUpCommandLine(base::CommandLine* command_line) override { | 226 void SetUpCommandLine(base::CommandLine* command_line) override { |
211 // ServiceWorkerRegistration.sync requires experimental flag. | 227 // ServiceWorkerRegistration.sync requires experimental flag. |
212 command_line->AppendSwitch( | 228 command_line->AppendSwitch( |
213 switches::kEnableExperimentalWebPlatformFeatures); | 229 switches::kEnableExperimentalWebPlatformFeatures); |
214 ServiceWorkerTest::SetUpCommandLine(command_line); | 230 ServiceWorkerTest::SetUpCommandLine(command_line); |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 837 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
822 web_contents, "window.runServiceWorker()", &result)); | 838 web_contents, "window.runServiceWorker()", &result)); |
823 ASSERT_EQ("SERVICE_WORKER_READY", result); | 839 ASSERT_EQ("SERVICE_WORKER_READY", result); |
824 | 840 |
825 EXPECT_FALSE(sync_listener.was_satisfied()); | 841 EXPECT_FALSE(sync_listener.was_satisfied()); |
826 // Resume firing by going online. | 842 // Resume firing by going online. |
827 content::background_sync_test_util::SetOnline(web_contents, true); | 843 content::background_sync_test_util::SetOnline(web_contents, true); |
828 EXPECT_TRUE(sync_listener.WaitUntilSatisfied()); | 844 EXPECT_TRUE(sync_listener.WaitUntilSatisfied()); |
829 } | 845 } |
830 | 846 |
| 847 IN_PROC_BROWSER_TEST_F(ServiceWorkerPaymentManagerTest, |
| 848 ShouldDisablePaymentManager) { |
| 849 const Extension* extension = LoadExtensionWithFlags( |
| 850 test_data_dir_.AppendASCII("service_worker/payments"), kFlagNone); |
| 851 ASSERT_TRUE(extension); |
| 852 ui_test_utils::NavigateToURL(browser(), |
| 853 extension->GetResourceURL("page.html")); |
| 854 content::WebContents* web_contents = |
| 855 browser()->tab_strip_model()->GetActiveWebContents(); |
| 856 |
| 857 std::string result; |
| 858 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 859 web_contents, "window.runServiceWorker()", &result)); |
| 860 ASSERT_EQ("SecurityError", result); |
| 861 } |
| 862 |
831 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, | 863 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, |
832 FetchFromContentScriptShouldNotGoToServiceWorkerOfPage) { | 864 FetchFromContentScriptShouldNotGoToServiceWorkerOfPage) { |
833 ASSERT_TRUE(StartEmbeddedTestServer()); | 865 ASSERT_TRUE(StartEmbeddedTestServer()); |
834 GURL page_url = embedded_test_server()->GetURL( | 866 GURL page_url = embedded_test_server()->GetURL( |
835 "/extensions/api_test/service_worker/content_script_fetch/" | 867 "/extensions/api_test/service_worker/content_script_fetch/" |
836 "controlled_page/index.html"); | 868 "controlled_page/index.html"); |
837 content::WebContents* tab = | 869 content::WebContents* tab = |
838 browser()->tab_strip_model()->GetActiveWebContents(); | 870 browser()->tab_strip_model()->GetActiveWebContents(); |
839 ui_test_utils::NavigateToURL(browser(), page_url); | 871 ui_test_utils::NavigateToURL(browser(), page_url); |
840 content::WaitForLoadStop(tab); | 872 content::WaitForLoadStop(tab); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 message.sender_id = "1234567890"; | 914 message.sender_id = "1234567890"; |
883 message.raw_data = "testdata"; | 915 message.raw_data = "testdata"; |
884 message.decrypted = true; | 916 message.decrypted = true; |
885 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 917 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
886 push_service()->OnMessage(app_identifier.app_id(), message); | 918 push_service()->OnMessage(app_identifier.app_id(), message); |
887 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); | 919 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); |
888 run_loop.Run(); // Wait until the message is handled by push service. | 920 run_loop.Run(); // Wait until the message is handled by push service. |
889 } | 921 } |
890 | 922 |
891 } // namespace extensions | 923 } // namespace extensions |
OLD | NEW |