| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base64.h" | 5 #include "base/base64.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
| 28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/test/browser_test_utils.h" | 29 #include "content/public/test/browser_test_utils.h" |
| 30 #include "extensions/browser/event_router.h" | 30 #include "extensions/browser/event_router.h" |
| 31 #include "extensions/browser/extension_prefs.h" | 31 #include "extensions/browser/extension_prefs.h" |
| 32 #include "extensions/browser/extension_system.h" | 32 #include "extensions/browser/extension_system.h" |
| 33 #include "extensions/common/api/runtime.h" | 33 #include "extensions/common/api/runtime.h" |
| 34 #include "extensions/common/extension_builder.h" | 34 #include "extensions/common/extension_builder.h" |
| 35 #include "extensions/common/value_builder.h" | 35 #include "extensions/common/value_builder.h" |
| 36 #include "extensions/test/extension_test_message_listener.h" |
| 37 #include "extensions/test/result_catcher.h" |
| 36 #include "net/cert/asn1_util.h" | 38 #include "net/cert/asn1_util.h" |
| 37 #include "net/cert/jwk_serializer.h" | 39 #include "net/cert/jwk_serializer.h" |
| 38 #include "net/dns/mock_host_resolver.h" | 40 #include "net/dns/mock_host_resolver.h" |
| 39 #include "net/ssl/channel_id_service.h" | 41 #include "net/ssl/channel_id_service.h" |
| 40 #include "net/test/embedded_test_server/embedded_test_server.h" | 42 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 41 #include "net/url_request/url_request_context.h" | 43 #include "net/url_request/url_request_context.h" |
| 42 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
| 43 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 44 | 46 |
| 45 namespace extensions { | 47 namespace extensions { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 107 |
| 106 content::NotificationRegistrar registrar_; | 108 content::NotificationRegistrar registrar_; |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 // Tests that message passing between extensions and content scripts works. | 111 // Tests that message passing between extensions and content scripts works. |
| 110 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Messaging) { | 112 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Messaging) { |
| 111 ASSERT_TRUE(StartEmbeddedTestServer()); | 113 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 112 ASSERT_TRUE(RunExtensionTest("messaging/connect")) << message_; | 114 ASSERT_TRUE(RunExtensionTest("messaging/connect")) << message_; |
| 113 } | 115 } |
| 114 | 116 |
| 117 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingCrash) { |
| 118 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 119 ExtensionTestMessageListener ready_to_crash("ready_to_crash", true); |
| 120 ASSERT_TRUE(LoadExtension( |
| 121 test_data_dir_.AppendASCII("messaging/connect_crash"))); |
| 122 ui_test_utils::NavigateToURL( |
| 123 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); |
| 124 content::WebContents* tab = |
| 125 browser()->tab_strip_model()->GetActiveWebContents(); |
| 126 EXPECT_TRUE(ready_to_crash.WaitUntilSatisfied()); |
| 127 |
| 128 ResultCatcher catcher; |
| 129 CrashTab(tab); |
| 130 EXPECT_TRUE(catcher.GetNextResult()); |
| 131 } |
| 132 |
| 115 // Tests that message passing from one extension to another works. | 133 // Tests that message passing from one extension to another works. |
| 116 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingExternal) { | 134 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingExternal) { |
| 117 ASSERT_TRUE(LoadExtension( | 135 ASSERT_TRUE(LoadExtension( |
| 118 test_data_dir_.AppendASCII("..").AppendASCII("good") | 136 test_data_dir_.AppendASCII("..").AppendASCII("good") |
| 119 .AppendASCII("Extensions") | 137 .AppendASCII("Extensions") |
| 120 .AppendASCII("bjafgdebaacbbbecmhlhpofkepfkgcpa") | 138 .AppendASCII("bjafgdebaacbbbecmhlhpofkepfkgcpa") |
| 121 .AppendASCII("1.0"))); | 139 .AppendASCII("1.0"))); |
| 122 | 140 |
| 123 ASSERT_TRUE(RunExtensionTest("messaging/connect_external")) << message_; | 141 ASSERT_TRUE(RunExtensionTest("messaging/connect_external")) << message_; |
| 124 } | 142 } |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); | 1218 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); |
| 1201 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, | 1219 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, |
| 1202 CanConnectAndSendMessagesToMainFrame(invalid.get())); | 1220 CanConnectAndSendMessagesToMainFrame(invalid.get())); |
| 1203 } | 1221 } |
| 1204 | 1222 |
| 1205 #endif // !defined(OS_WIN) - http://crbug.com/350517. | 1223 #endif // !defined(OS_WIN) - http://crbug.com/350517. |
| 1206 | 1224 |
| 1207 } // namespace | 1225 } // namespace |
| 1208 | 1226 |
| 1209 }; // namespace extensions | 1227 }; // namespace extensions |
| OLD | NEW |