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

Unified 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: Fixed syntax errors 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | chrome/common/extensions/message_bundle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/content_script_apitest.cc
diff --git a/chrome/browser/extensions/content_script_apitest.cc b/chrome/browser/extensions/content_script_apitest.cc
index bbee2a47f5f5820458206a92255e04e60ddf80e0..96685e4bca12e825bcb6e9afe2aeefdca1b33fe2 100644
--- a/chrome/browser/extensions/content_script_apitest.cc
+++ b/chrome/browser/extensions/content_script_apitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/file_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/api/permissions/permissions_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
@@ -174,3 +175,50 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptBypassPageCSP) {
ASSERT_TRUE(StartTestServer());
ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_;
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptUpdatei18nMessages) {
+ ASSERT_TRUE(StartTestServer());
+ // Create an Extension whos messages.json file is to be updated.
+ base::FilePath extension_dir;
+ file_util::CreateNewTempDirectory("", &extension_dir);
+ file_util::CopyFile(
+ test_data_dir_.AppendASCII(
+ "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.
+ extension_dir.AppendASCII("manifest.json"));
+ file_util::CopyFile(
+ test_data_dir_.AppendASCII(
+ "content_scripts/message_reload1/contentscript.js"),
+ extension_dir.AppendASCII("contentscript.js"));
+ file_util::CopyDirectory(
+ test_data_dir_.AppendASCII("content_scripts/message_reload1/_locales"),
+ extension_dir.AppendASCII("_locales"),
+ true);
+
+ const extensions::Extension* extension = LoadExtension(extension_dir);
+
+ ResultCatcher catcher;
+
+ // Test that the messages.json file is loaded and the i18n message is loaded.
+ ui_test_utils::NavigateToURL(
+ browser(), test_server()->GetURL("file/extensions/test_file.html"));
+ EXPECT_TRUE(catcher.GetNextResult());
+
+ string16 title;
+ ui_test_utils::GetCurrentTabTitle(browser(), &title);
+ EXPECT_EQ(std::string("FIRSTMESSAGE"), UTF16ToUTF8(title));
+
+ // Change messages.json file and reload extension.
+ file_util::CopyFile(
+ test_data_dir_.AppendASCII(
+ "content_scripts/message_reload1/messages2.json"),
+ extension_dir.AppendASCII("_locales/en/messages.json"));
+ ReloadExtension(extension->id());
+
+ // Check that the i18n message is also changed.
+ ui_test_utils::NavigateToURL(
+ browser(), test_server()->GetURL("file/extensions/test_file.html"));
+ EXPECT_TRUE(catcher.GetNextResult());
+
+ ui_test_utils::GetCurrentTabTitle(browser(), &title);
+ EXPECT_EQ(std::string("SECONDMESSAGE"), UTF16ToUTF8(title));
+}
« no previous file with comments | « AUTHORS ('k') | chrome/common/extensions/message_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698