| 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 // Contains holistic tests of the bindings infrastructure | 5 // Contains holistic tests of the bindings infrastructure |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/permissions/permissions_api.h" | 7 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/net/url_request_mock_util.h" | 9 #include "chrome/browser/net/url_request_mock_util.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // See chrome/test/data/extensions/api_test/bindings/override_exports.html. | 131 // See chrome/test/data/extensions/api_test/bindings/override_exports.html. |
| 132 std::string result; | 132 std::string result; |
| 133 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 133 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 134 browser()->tab_strip_model()->GetActiveWebContents(), | 134 browser()->tab_strip_model()->GetActiveWebContents(), |
| 135 "window.domAutomationController.send(" | 135 "window.domAutomationController.send(" |
| 136 "document.getElementById('status').textContent.trim());", | 136 "document.getElementById('status').textContent.trim());", |
| 137 &result)); | 137 &result)); |
| 138 EXPECT_EQ("success", result); | 138 EXPECT_EQ("success", result); |
| 139 } | 139 } |
| 140 | 140 |
| 141 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, NoGinDefineOverriding) { |
| 142 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 143 |
| 144 // We need to create runtime bindings in the web page. An extension that's |
| 145 // externally connectable will do that for us. |
| 146 ASSERT_TRUE(LoadExtension( |
| 147 test_data_dir_.AppendASCII("bindings") |
| 148 .AppendASCII("externally_connectable_everywhere"))); |
| 149 |
| 150 ui_test_utils::NavigateToURL( |
| 151 browser(), |
| 152 embedded_test_server()->GetURL( |
| 153 "/extensions/api_test/bindings/override_gin_define.html")); |
| 154 ASSERT_FALSE( |
| 155 browser()->tab_strip_model()->GetActiveWebContents()->IsCrashed()); |
| 156 |
| 157 // See chrome/test/data/extensions/api_test/bindings/override_gin_define.html. |
| 158 std::string result; |
| 159 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 160 browser()->tab_strip_model()->GetActiveWebContents(), |
| 161 "window.domAutomationController.send(" |
| 162 "document.getElementById('status').textContent.trim());", |
| 163 &result)); |
| 164 EXPECT_EQ("success", result); |
| 165 } |
| 166 |
| 141 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, HandlerFunctionTypeChecking) { | 167 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, HandlerFunctionTypeChecking) { |
| 142 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 168 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 143 ui_test_utils::NavigateToURL( | 169 ui_test_utils::NavigateToURL( |
| 144 browser(), | 170 browser(), |
| 145 embedded_test_server()->GetURL( | 171 embedded_test_server()->GetURL( |
| 146 "/extensions/api_test/bindings/handler_function_type_checking.html")); | 172 "/extensions/api_test/bindings/handler_function_type_checking.html")); |
| 147 content::WebContents* web_contents = | 173 content::WebContents* web_contents = |
| 148 browser()->tab_strip_model()->GetActiveWebContents(); | 174 browser()->tab_strip_model()->GetActiveWebContents(); |
| 149 EXPECT_FALSE(web_contents->IsCrashed()); | 175 EXPECT_FALSE(web_contents->IsCrashed()); |
| 150 // See handler_function_type_checking.html. | 176 // See handler_function_type_checking.html. |
| 151 std::string result; | 177 std::string result; |
| 152 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 178 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 153 web_contents, | 179 web_contents, |
| 154 "window.domAutomationController.send(" | 180 "window.domAutomationController.send(" |
| 155 "document.getElementById('status').textContent.trim());", | 181 "document.getElementById('status').textContent.trim());", |
| 156 &result)); | 182 &result)); |
| 157 EXPECT_EQ("success", result); | 183 EXPECT_EQ("success", result); |
| 158 } | 184 } |
| 159 | 185 |
| 160 } // namespace | 186 } // namespace |
| 161 } // namespace extensions | 187 } // namespace extensions |
| OLD | NEW |