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

Unified Diff: chrome/browser/extensions/content_script_apitest.cc

Issue 2116613002: Prevent duplicate content script injection defined in manifest.json (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests Added Created 4 years, 5 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
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 c8d442885dff659576a6f2f6fc95385d298d0f84..93cf25dc90538f00209beb0ea8599c4ed33fc353 100644
--- a/chrome/browser/extensions/content_script_apitest.cc
+++ b/chrome/browser/extensions/content_script_apitest.cc
@@ -335,6 +335,31 @@ class ContentScriptCssInjectionTest : public ExtensionApiTest {
}
};
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
Devlin 2016/07/11 23:45:50 Though we don't do it uniformly, I think a comment
catmullings 2016/07/12 22:23:26 Done.
catmullings 2016/07/12 22:23:26 Thanks Devlin. I like the comment you've written.
+ ContentScriptDuplicateScriptInjection) {
+ host_resolver()->AddRule("maps.google.com", "127.0.0.1");
+ ASSERT_TRUE(StartEmbeddedTestServer());
+
+ std::string port_string = base::UintToString(embedded_test_server()->port());
+ GURL url = GURL("http://maps.google.com:"
Devlin 2016/07/11 23:45:50 We have handy utility called base::StringPrintf, w
catmullings 2016/07/12 22:23:26 Done.
+ + port_string
+ + "/extensions/test_file.html");
+
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("content_scripts/duplicate_script_injection")));
Devlin 2016/07/11 23:45:50 the indentation here is off (feel free to just run
catmullings 2016/07/12 22:23:26 Done.
+
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ bool scripts_injected_once;
Devlin 2016/07/11 23:45:50 All variables should be initialized at creation.
catmullings 2016/07/12 22:23:26 Done.
catmullings 2016/07/12 22:23:26 Many variables in this file are left uninitialized
Devlin 2016/07/12 23:32:36 I can't find any examples of uninitialized variabl
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "window.domAutomationController.send("
+ "document.getElementsByClassName('test-duplicate-script-injection')"
+ ".length == 1)",
+ &scripts_injected_once));
+ ASSERT_TRUE(scripts_injected_once);
+}
+
IN_PROC_BROWSER_TEST_F(ContentScriptCssInjectionTest,
ContentScriptInjectsStyles) {
ASSERT_TRUE(StartEmbeddedTestServer());

Powered by Google App Engine
This is Rietveld 408576698