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/file_util.h" | |
5 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/extensions/api/permissions/permissions_api.h" | 7 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 PermissionsRequestFunction::SetAutoConfirmForTests(true); | 168 PermissionsRequestFunction::SetAutoConfirmForTests(true); |
168 host_resolver()->AddRule("*.com", "127.0.0.1"); | 169 host_resolver()->AddRule("*.com", "127.0.0.1"); |
169 ASSERT_TRUE(StartTestServer()); | 170 ASSERT_TRUE(StartTestServer()); |
170 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; | 171 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; |
171 } | 172 } |
172 | 173 |
173 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptBypassPageCSP) { | 174 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptBypassPageCSP) { |
174 ASSERT_TRUE(StartTestServer()); | 175 ASSERT_TRUE(StartTestServer()); |
175 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_; | 176 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_; |
176 } | 177 } |
178 | |
179 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptUpdatei18nMessages) { | |
180 ASSERT_TRUE(StartTestServer()); | |
181 // Create an Extension whos messages.json file is to be updated. | |
182 base::FilePath extension_dir; | |
183 file_util::CreateNewTempDirectory("", &extension_dir); | |
184 file_util::CopyFile( | |
185 test_data_dir_.AppendASCII( | |
186 "content_scripts/message_reload1/manifest.json"), | |
Devlin
2013/02/26 05:57:12
It's better form to append one thing at a time; i.
Patrick Riordan
2013/02/27 18:30:16
Done.
| |
187 extension_dir.AppendASCII("manifest.json")); | |
188 file_util::CopyFile( | |
189 test_data_dir_.AppendASCII( | |
190 "content_scripts/message_reload1/contentscript.js"), | |
191 extension_dir.AppendASCII("contentscript.js")); | |
192 file_util::CopyDirectory( | |
193 test_data_dir_.AppendASCII("content_scripts/message_reload1/_locales"), | |
194 extension_dir.AppendASCII("_locales"), | |
195 true); | |
196 | |
197 const extensions::Extension* extension = LoadExtension(extension_dir); | |
198 | |
199 ResultCatcher catcher; | |
200 | |
201 // Test that the messages.json file is loaded and the i18n message is loaded. | |
202 ui_test_utils::NavigateToURL( | |
203 browser(), test_server()->GetURL("file/extensions/test_file.html")); | |
204 EXPECT_TRUE(catcher.GetNextResult()); | |
205 | |
206 string16 title; | |
207 ui_test_utils::GetCurrentTabTitle(browser(), &title); | |
208 EXPECT_EQ(std::string("FIRSTMESSAGE"), UTF16ToUTF8(title)); | |
209 | |
210 // Change messages.json file and reload extension. | |
211 file_util::CopyFile( | |
212 test_data_dir_.AppendASCII( | |
213 "content_scripts/message_reload1/messages2.json"), | |
214 extension_dir.AppendASCII("_locales/en/messages.json")); | |
215 ReloadExtension(extension->id()); | |
216 | |
217 // Check that the i18n message is also changed. | |
218 ui_test_utils::NavigateToURL( | |
219 browser(), test_server()->GetURL("file/extensions/test_file.html")); | |
220 EXPECT_TRUE(catcher.GetNextResult()); | |
221 | |
222 ui_test_utils::GetCurrentTabTitle(browser(), &title); | |
223 EXPECT_EQ(std::string("SECONDMESSAGE"), UTF16ToUTF8(title)); | |
224 } | |
OLD | NEW |