Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: chrome/browser/extensions/content_script_apitest.cc

Issue 12319073: Delete the extensions i18n message map when extension unload is received. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 {
Devlin 2013/02/22 19:59:07 Bracket on same line as function name.
Patrick Riordan 2013/02/26 05:05:20 Done.
181 ASSERT_TRUE(StartTestServer());
182 // Create Extension whos messages.json file is to be updated.
Devlin 2013/02/22 19:59:07 Make comments grammatically correct. "Create _an_
Patrick Riordan 2013/02/26 05:05:20 Done.
Devlin 2013/02/26 05:57:12 Still need to fix 'whos' to 'whose'. (I might also
Patrick Riordan 2013/02/27 18:30:16 Done.
183 base::FilePath extdir;
Devlin 2013/02/22 19:59:07 As a rule, we try to avoid abbreviating variable n
Patrick Riordan 2013/02/26 05:05:20 Done.
184 file_util::CreateNewTempDirectory("",&extdir);
185 file_util::CopyFile(
186 test_data_dir_.AppendASCII(
187 "content_scripts/message_reload1/manifest.json"),
188 extdir.AppendASCII("manifest.json"));
189 file_util::CopyFile(
190 test_data_dir_.AppendASCII(
191 "content_scripts/message_reload1/contentscript.js"),
192 extdir.AppendASCII("contentscript.js"));
193 file_util::CopyDirectory(
194 test_data_dir_.AppendASCII("content_scripts/message_reload1/_locales"),
195 extdir.AppendASCII("_locales"),
196 true);
197
198 const extensions::Extension*extension = LoadExtension(extdir);
Devlin 2013/02/22 19:59:07 Space between Extension* and extension.
Patrick Riordan 2013/02/26 05:05:20 Done.
199
200 ResultCatcher catcher;
201
202 //Test messages.json file is loaded and the i18n message is loaded.
Devlin 2013/02/22 19:59:07 Space after comment beginning (i.e. "// Test...")
Patrick Riordan 2013/02/26 05:05:20 Done.
203 ui_test_utils::NavigateToURL(
204 browser(), test_server()->GetURL("file/extensions/test_file.html"));
205
206 EXPECT_TRUE(catcher.GetNextResult());
207
208 string16 title;
209
210 ui_test_utils::GetCurrentTabTitle(browser(),&title);
Devlin 2013/02/22 19:59:07 Space between arguments.
Patrick Riordan 2013/02/26 05:05:20 Done.
211
212 EXPECT_EQ(std::string("FIRSTMESSAGE"), UTF16ToUTF8(title));
213
214 //Change messages.json file and reload extension.
215 file_util::CopyFile(
216 test_data_dir_.AppendASCII(
217 "content_scripts/message_reload1/messages.json"),
218 extdir.AppendASCII("_locales/en/messages.json"));
219
220 ReloadExtension(extension->id());
221
222 //Check i18n message is also changed.
Devlin 2013/02/22 19:59:07 "Check _that the_ i18n message..."
Patrick Riordan 2013/02/26 05:05:20 Done.
223 ui_test_utils::NavigateToURL(
224 browser(), test_server()->GetURL("file/extensions/test_file.html"));
225
226 EXPECT_TRUE(catcher.GetNextResult());
227
228 ui_test_utils::GetCurrentTabTitle(browser(),&title);
229
230 EXPECT_EQ(std::string("SECONDMESSAGE"), UTF16ToUTF8(title));
Devlin 2013/02/22 19:59:07 There seems to be too many newlines between 204 an
Patrick Riordan 2013/02/26 05:05:20 Done.
231 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698