Chromium Code Reviews| 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..25de32deca4633ab731a7cd48abd885bc078ed62 100644 |
| --- a/chrome/browser/extensions/content_script_apitest.cc |
| +++ b/chrome/browser/extensions/content_script_apitest.cc |
| @@ -335,6 +335,41 @@ class ContentScriptCssInjectionTest : public ExtensionApiTest { |
| } |
| }; |
| +// Test that a script that matches two separate match patterns is only |
| +// injected once. |
| +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, |
| + ContentScriptDuplicateScriptInjection) { |
| + host_resolver()->AddRule("maps.google.com", "127.0.0.1"); |
| + ASSERT_TRUE(StartEmbeddedTestServer()); |
| + |
| + GURL url = GURL( |
|
Devlin
2016/07/19 16:09:00
nit: no reason for assignment instead of just cons
catmullings
2016/07/19 17:10:51
Done.
|
| + base::StringPrintf("http://maps.google.com:%i/extensions/test_file.html", |
| + embedded_test_server()->port())); |
| + |
| + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( |
| + "content_scripts/duplicate_script_injection"))); |
| + |
| + ui_test_utils::NavigateToURL(browser(), url); |
| + |
| + bool scripts_injected_once = false; |
|
Devlin
2016/07/19 16:09:00
these variables are somewhat opaque from the test
catmullings
2016/07/19 17:10:50
Moved the comment describing the entire TEST_F to
|
| + 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); |
| + |
| + bool scripts_injected_twice = false; |
| + ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| + browser()->tab_strip_model()->GetActiveWebContents(), |
| + "window.domAutomationController.send(" |
| + "document.getElementsByClassName('injected-twice')" |
| + ".length == 2)", |
| + &scripts_injected_twice)); |
| + ASSERT_TRUE(scripts_injected_twice); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(ContentScriptCssInjectionTest, |
| ContentScriptInjectsStyles) { |
| ASSERT_TRUE(StartEmbeddedTestServer()); |