| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 testing::AssertionResult AreAnyNonWebApisDefinedForIFrame() { | 206 testing::AssertionResult AreAnyNonWebApisDefinedForIFrame() { |
| 207 content::RenderFrameHost* frame = content::FrameMatchingPredicate( | 207 content::RenderFrameHost* frame = content::FrameMatchingPredicate( |
| 208 browser()->tab_strip_model()->GetActiveWebContents(), | 208 browser()->tab_strip_model()->GetActiveWebContents(), |
| 209 base::Bind(&content::FrameIsChildOfMainFrame)); | 209 base::Bind(&content::FrameIsChildOfMainFrame)); |
| 210 return AreAnyNonWebApisDefinedForFrame(frame); | 210 return AreAnyNonWebApisDefinedForFrame(frame); |
| 211 } | 211 } |
| 212 | 212 |
| 213 testing::AssertionResult AreAnyNonWebApisDefinedForFrame( | 213 testing::AssertionResult AreAnyNonWebApisDefinedForFrame( |
| 214 content::RenderFrameHost* frame) { | 214 content::RenderFrameHost* frame) { |
| 215 // All runtime API methods are non-web except for sendRequest and connect. | 215 // All runtime API methods are non-web except for sendRequest and connect. |
| 216 const char* non_messaging_apis[] = { | 216 const char* const non_messaging_apis[] = { |
| 217 "getBackgroundPage", | 217 "getBackgroundPage", |
| 218 "getManifest", | 218 "getManifest", |
| 219 "getURL", | 219 "getURL", |
| 220 "reload", | 220 "reload", |
| 221 "requestUpdateCheck", | 221 "requestUpdateCheck", |
| 222 "restart", | 222 "restart", |
| 223 "connectNative", | 223 "connectNative", |
| 224 "sendNativeMessage", | 224 "sendNativeMessage", |
| 225 "onStartup", | 225 "onStartup", |
| 226 "onInstalled", | 226 "onInstalled", |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 // closes upon receipt of the connect. | 615 // closes upon receipt of the connect. |
| 616 std::string tls_channel_id = GetTlsChannelIdFromPortConnect( | 616 std::string tls_channel_id = GetTlsChannelIdFromPortConnect( |
| 617 chromium_connectable.get(), true, close_background_message()); | 617 chromium_connectable.get(), true, close_background_message()); |
| 618 // Because the TLS channel ID has never been generated for this domain, | 618 // Because the TLS channel ID has never been generated for this domain, |
| 619 // no TLS channel ID is reported. | 619 // no TLS channel ID is reported. |
| 620 EXPECT_EQ(std::string(), tls_channel_id); | 620 EXPECT_EQ(std::string(), tls_channel_id); |
| 621 // A subsequent connect will still succeed, even if the background page was | 621 // A subsequent connect will still succeed, even if the background page was |
| 622 // previously closed. | 622 // previously closed. |
| 623 tls_channel_id = | 623 tls_channel_id = |
| 624 GetTlsChannelIdFromPortConnect(chromium_connectable.get(), true); | 624 GetTlsChannelIdFromPortConnect(chromium_connectable.get(), true); |
| 625 // And the empty value is still retrieved. | 625 // And the empty value is still retrieved. |
| 626 EXPECT_EQ(std::string(), tls_channel_id); | 626 EXPECT_EQ(std::string(), tls_channel_id); |
| 627 } | 627 } |
| 628 | 628 |
| 629 // Tests that enabling and disabling an extension makes the runtime bindings | 629 // Tests that enabling and disabling an extension makes the runtime bindings |
| 630 // appear and disappear. | 630 // appear and disappear. |
| 631 // | 631 // |
| 632 // TODO(kalman): Test with multiple extensions that can be accessed by the same | 632 // TODO(kalman): Test with multiple extensions that can be accessed by the same |
| 633 // host. | 633 // host. |
| 634 IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, | 634 IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, |
| 635 EnablingAndDisabling) { | 635 EnablingAndDisabling) { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); | 980 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); |
| 981 // If the page does ask for it, it isn't empty, even if the background page | 981 // If the page does ask for it, it isn't empty, even if the background page |
| 982 // closes upon receipt of the connect. | 982 // closes upon receipt of the connect. |
| 983 std::string tls_channel_id = GetTlsChannelIdFromPortConnect( | 983 std::string tls_channel_id = GetTlsChannelIdFromPortConnect( |
| 984 chromium_connectable.get(), true, close_background_message()); | 984 chromium_connectable.get(), true, close_background_message()); |
| 985 EXPECT_EQ(expected_tls_channel_id_value, tls_channel_id); | 985 EXPECT_EQ(expected_tls_channel_id_value, tls_channel_id); |
| 986 // A subsequent connect will still succeed, even if the background page was | 986 // A subsequent connect will still succeed, even if the background page was |
| 987 // previously closed. | 987 // previously closed. |
| 988 tls_channel_id = | 988 tls_channel_id = |
| 989 GetTlsChannelIdFromPortConnect(chromium_connectable.get(), true); | 989 GetTlsChannelIdFromPortConnect(chromium_connectable.get(), true); |
| 990 // And the expected value is still retrieved. | 990 // And the expected value is still retrieved. |
| 991 EXPECT_EQ(expected_tls_channel_id_value, tls_channel_id); | 991 EXPECT_EQ(expected_tls_channel_id_value, tls_channel_id); |
| 992 } | 992 } |
| 993 | 993 |
| 994 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingUserGesture) { | 994 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingUserGesture) { |
| 995 const char kManifest[] = "{" | 995 const char kManifest[] = "{" |
| 996 " \"name\": \"user_gesture\"," | 996 " \"name\": \"user_gesture\"," |
| 997 " \"version\": \"1.0\"," | 997 " \"version\": \"1.0\"," |
| 998 " \"background\": {" | 998 " \"background\": {" |
| 999 " \"scripts\": [\"background.js\"]" | 999 " \"scripts\": [\"background.js\"]" |
| 1000 " }," | 1000 " }," |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); | 1081 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); |
| 1082 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, | 1082 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, |
| 1083 CanConnectAndSendMessagesToMainFrame(invalid.get())); | 1083 CanConnectAndSendMessagesToMainFrame(invalid.get())); |
| 1084 } | 1084 } |
| 1085 | 1085 |
| 1086 #endif // !defined(OS_WIN) - http://crbug.com/350517. | 1086 #endif // !defined(OS_WIN) - http://crbug.com/350517. |
| 1087 | 1087 |
| 1088 } // namespace | 1088 } // namespace |
| 1089 | 1089 |
| 1090 }; // namespace extensions | 1090 }; // namespace extensions |
| OLD | NEW |