Chromium Code Reviews| 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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
| 6 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 6 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 7 #include "components/version_info/version_info.h" | 7 #include "components/version_info/version_info.h" |
| 8 #include "content/public/test/browser_test_utils.h" | 8 #include "content/public/test/browser_test_utils.h" |
| 9 #include "extensions/test/extension_test_message_listener.h" | 9 #include "extensions/test/extension_test_message_listener.h" |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 ExtensionTestMessageListener listener(false); | 36 ExtensionTestMessageListener listener(false); |
| 37 ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_; | 37 ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_; |
| 38 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 38 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 39 EXPECT_EQ( | 39 EXPECT_EQ( |
| 40 "SecurityError: Failed to register a ServiceWorker: The URL " | 40 "SecurityError: Failed to register a ServiceWorker: The URL " |
| 41 "protocol of the current origin ('chrome-extension://" + | 41 "protocol of the current origin ('chrome-extension://" + |
| 42 GetSingleLoadedExtension()->id() + "') is not supported.", | 42 GetSingleLoadedExtension()->id() + "') is not supported.", |
| 43 listener.message()); | 43 listener.message()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, ServiceWorkerFetchEvent) { | 46 // Disabled: crbug.com/529516. |
| 47 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, DISABLED_ServiceWorkerFetchEvent) { | |
|
Devlin
2015/09/09 15:35:00
:( Were these flaky?
Devlin
2015/09/09 15:35:44
I guess I should have read the email that came in
| |
| 47 RunExtensionTest("service_worker/fetch"); | 48 RunExtensionTest("service_worker/fetch"); |
| 48 content::WebContents* contents = | 49 content::WebContents* contents = |
| 49 browser()->tab_strip_model()->GetActiveWebContents(); | 50 browser()->tab_strip_model()->GetActiveWebContents(); |
| 50 content::WaitForLoadStop(contents); | 51 content::WaitForLoadStop(contents); |
| 51 | 52 |
| 52 std::string output; | 53 std::string output; |
| 53 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 54 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 54 contents, "window.domAutomationController.send(document.body.innerText);", | 55 contents, "window.domAutomationController.send(document.body.innerText);", |
| 55 &output)); | 56 &output)); |
| 56 EXPECT_EQ("No Fetch Event yet.", output); | 57 EXPECT_EQ("No Fetch Event yet.", output); |
| 57 | 58 |
| 58 // Page must reload in order for the service worker to take control. | 59 // Page must reload in order for the service worker to take control. |
| 59 contents->GetController().Reload(true); | 60 contents->GetController().Reload(true); |
| 60 content::WaitForLoadStop(contents); | 61 content::WaitForLoadStop(contents); |
| 61 | 62 |
| 62 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 63 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 63 contents, "window.domAutomationController.send(document.body.innerText);", | 64 contents, "window.domAutomationController.send(document.body.innerText);", |
| 64 &output)); | 65 &output)); |
| 65 EXPECT_EQ("Caught a fetch!", output); | 66 EXPECT_EQ("Caught a fetch!", output); |
| 66 } | 67 } |
| 67 | 68 |
| 68 // Binding that was created on the v8::Context of the worker for testing | 69 // Binding that was created on the v8::Context of the worker for testing |
| 69 // purposes should bind an object to chrome. | 70 // purposes should bind an object to chrome. |
| 70 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, ServiceWorkerChromeBinding) { | 71 // Disabled: crbug.com/529516. |
| 72 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, DISABLED_ServiceWorkerChromeBinding) { | |
| 71 ASSERT_TRUE(RunExtensionTest("service_worker/bindings")) << message_; | 73 ASSERT_TRUE(RunExtensionTest("service_worker/bindings")) << message_; |
| 72 content::WebContents* contents = | 74 content::WebContents* contents = |
| 73 browser()->tab_strip_model()->GetActiveWebContents(); | 75 browser()->tab_strip_model()->GetActiveWebContents(); |
| 74 content::WaitForLoadStop(contents); | 76 content::WaitForLoadStop(contents); |
| 75 | 77 |
| 76 std::string output; | 78 std::string output; |
| 77 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 79 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 78 contents, "window.domAutomationController.send(document.body.innerText);", | 80 contents, "window.domAutomationController.send(document.body.innerText);", |
| 79 &output)); | 81 &output)); |
| 80 EXPECT_EQ("No Fetch Event yet.", output); | 82 EXPECT_EQ("No Fetch Event yet.", output); |
| 81 | 83 |
| 82 // Page must reload in order for the service worker to take control. | 84 // Page must reload in order for the service worker to take control. |
| 83 contents->GetController().Reload(true); | 85 contents->GetController().Reload(true); |
| 84 content::WaitForLoadStop(contents); | 86 content::WaitForLoadStop(contents); |
| 85 | 87 |
| 86 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 88 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 87 contents, "window.domAutomationController.send(document.body.innerText);", | 89 contents, "window.domAutomationController.send(document.body.innerText);", |
| 88 &output)); | 90 &output)); |
| 89 EXPECT_EQ("object", output); | 91 EXPECT_EQ("object", output); |
| 90 } | 92 } |
| 91 | 93 |
| 92 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, GetBackgroundClient) { | 94 // Disabled: crbug.com/529516. |
| 95 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, DISABLED_GetBackgroundClient) { | |
| 93 ASSERT_TRUE(RunExtensionTest("service_worker/background_client")) << message_; | 96 ASSERT_TRUE(RunExtensionTest("service_worker/background_client")) << message_; |
| 94 content::WebContents* contents = | 97 content::WebContents* contents = |
| 95 browser()->tab_strip_model()->GetActiveWebContents(); | 98 browser()->tab_strip_model()->GetActiveWebContents(); |
| 96 content::WaitForLoadStop(contents); | 99 content::WaitForLoadStop(contents); |
| 97 | 100 |
| 98 std::string output; | 101 std::string output; |
| 99 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 102 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 100 contents, "window.domAutomationController.send(document.body.innerText);", | 103 contents, "window.domAutomationController.send(document.body.innerText);", |
| 101 &output)); | 104 &output)); |
| 102 EXPECT_EQ("No Fetch Event yet.", output); | 105 EXPECT_EQ("No Fetch Event yet.", output); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 117 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, PostMessageToBackgroundClient) { | 120 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, PostMessageToBackgroundClient) { |
| 118 ASSERT_TRUE(RunExtensionTest("service_worker/post_messaging")) << message_; | 121 ASSERT_TRUE(RunExtensionTest("service_worker/post_messaging")) << message_; |
| 119 | 122 |
| 120 EXPECT_EQ("Hello from the SW!", | 123 EXPECT_EQ("Hello from the SW!", |
| 121 ExecuteScriptInBackgroundPage( | 124 ExecuteScriptInBackgroundPage( |
| 122 GetSingleLoadedExtension()->id(), | 125 GetSingleLoadedExtension()->id(), |
| 123 "window.domAutomationController.send(message);")); | 126 "window.domAutomationController.send(message);")); |
| 124 } | 127 } |
| 125 | 128 |
| 126 } // namespace extensions | 129 } // namespace extensions |
| OLD | NEW |