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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 // could lead to spoofing). Unfortunately, host_resolver seems to have | 328 // could lead to spoofing). Unfortunately, host_resolver seems to have |
329 // problems with redirecting "chrome.google.com" to the test server, so we | 329 // problems with redirecting "chrome.google.com" to the test server, so we |
330 // can't use the real Webstore's URL. If this changes, we could clean this | 330 // can't use the real Webstore's URL. If this changes, we could clean this |
331 // up. | 331 // up. |
332 command_line->AppendSwitchASCII( | 332 command_line->AppendSwitchASCII( |
333 switches::kAppsGalleryURL, | 333 switches::kAppsGalleryURL, |
334 base::StringPrintf("http://%s", kWebstoreDomain)); | 334 base::StringPrintf("http://%s", kWebstoreDomain)); |
335 } | 335 } |
336 }; | 336 }; |
337 | 337 |
338 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.
| |
339 ContentScriptDuplicateScriptInjection) { | |
340 host_resolver()->AddRule("maps.google.com", "127.0.0.1"); | |
341 ASSERT_TRUE(StartEmbeddedTestServer()); | |
342 | |
343 std::string port_string = base::UintToString(embedded_test_server()->port()); | |
344 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.
| |
345 + port_string | |
346 + "/extensions/test_file.html"); | |
347 | |
348 ASSERT_TRUE(LoadExtension( | |
349 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.
| |
350 | |
351 ui_test_utils::NavigateToURL(browser(), url); | |
352 | |
353 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
| |
354 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
355 browser()->tab_strip_model()->GetActiveWebContents(), | |
356 "window.domAutomationController.send(" | |
357 "document.getElementsByClassName('test-duplicate-script-injection')" | |
358 ".length == 1)", | |
359 &scripts_injected_once)); | |
360 ASSERT_TRUE(scripts_injected_once); | |
361 } | |
362 | |
338 IN_PROC_BROWSER_TEST_F(ContentScriptCssInjectionTest, | 363 IN_PROC_BROWSER_TEST_F(ContentScriptCssInjectionTest, |
339 ContentScriptInjectsStyles) { | 364 ContentScriptInjectsStyles) { |
340 ASSERT_TRUE(StartEmbeddedTestServer()); | 365 ASSERT_TRUE(StartEmbeddedTestServer()); |
341 host_resolver()->AddRule(kWebstoreDomain, "127.0.0.1"); | 366 host_resolver()->AddRule(kWebstoreDomain, "127.0.0.1"); |
342 | 367 |
343 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("content_scripts") | 368 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("content_scripts") |
344 .AppendASCII("css_injection"))); | 369 .AppendASCII("css_injection"))); |
345 | 370 |
346 // CSS injection should be allowed on an aribitrary web page. | 371 // CSS injection should be allowed on an aribitrary web page. |
347 GURL url = | 372 GURL url = |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 ExtensionTestMessageListener iframe_loaded_listener("iframe loaded", false); | 654 ExtensionTestMessageListener iframe_loaded_listener("iframe loaded", false); |
630 ExtensionTestMessageListener content_script_listener("script injected", | 655 ExtensionTestMessageListener content_script_listener("script injected", |
631 false); | 656 false); |
632 LoadExtension(data_dir.AppendASCII("script_a_com")); | 657 LoadExtension(data_dir.AppendASCII("script_a_com")); |
633 LoadExtension(data_dir.AppendASCII("background_page_iframe")); | 658 LoadExtension(data_dir.AppendASCII("background_page_iframe")); |
634 iframe_loaded_listener.WaitUntilSatisfied(); | 659 iframe_loaded_listener.WaitUntilSatisfied(); |
635 EXPECT_FALSE(content_script_listener.was_satisfied()); | 660 EXPECT_FALSE(content_script_listener.was_satisfied()); |
636 } | 661 } |
637 | 662 |
638 } // namespace extensions | 663 } // namespace extensions |
OLD | NEW |