OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/active_script_controller.h" | 8 #include "chrome/browser/extensions/active_script_controller.h" |
9 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // before this method returns (as content::ExecuteScript() is synchronous). | 64 // before this method returns (as content::ExecuteScript() is synchronous). |
65 return content::ExecuteScript(web_contents, "1 == 1;"); | 65 return content::ExecuteScript(web_contents, "1 == 1;"); |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 class ActiveScriptControllerBrowserTest : public ExtensionBrowserTest { | 70 class ActiveScriptControllerBrowserTest : public ExtensionBrowserTest { |
71 public: | 71 public: |
72 ActiveScriptControllerBrowserTest() {} | 72 ActiveScriptControllerBrowserTest() {} |
73 | 73 |
74 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; | 74 virtual void SetUpCommandLine(base::CommandLine* command_line) override; |
75 virtual void TearDownOnMainThread() OVERRIDE; | 75 virtual void TearDownOnMainThread() override; |
76 | 76 |
77 // Returns an extension with the given |host_type| and |injection_type|. If | 77 // Returns an extension with the given |host_type| and |injection_type|. If |
78 // one already exists, the existing extension will be returned. Othewrwise, | 78 // one already exists, the existing extension will be returned. Othewrwise, |
79 // one will be created. | 79 // one will be created. |
80 // This could potentially return NULL if LoadExtension() fails. | 80 // This could potentially return NULL if LoadExtension() fails. |
81 const Extension* CreateExtension(HostType host_type, | 81 const Extension* CreateExtension(HostType host_type, |
82 InjectionType injection_type); | 82 InjectionType injection_type); |
83 | 83 |
84 private: | 84 private: |
85 ScopedVector<TestExtensionDir> test_extension_dirs_; | 85 ScopedVector<TestExtensionDir> test_extension_dirs_; |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 active_script_controller->OnClicked(extension1); | 401 active_script_controller->OnClicked(extension1); |
402 inject_success_listener.WaitUntilSatisfied(); | 402 inject_success_listener.WaitUntilSatisfied(); |
403 } | 403 } |
404 | 404 |
405 // A version of the test with the flag off, in order to test that everything | 405 // A version of the test with the flag off, in order to test that everything |
406 // still works as expected. | 406 // still works as expected. |
407 class FlagOffActiveScriptControllerBrowserTest | 407 class FlagOffActiveScriptControllerBrowserTest |
408 : public ActiveScriptControllerBrowserTest { | 408 : public ActiveScriptControllerBrowserTest { |
409 private: | 409 private: |
410 // Simply don't append the flag. | 410 // Simply don't append the flag. |
411 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE { | 411 virtual void SetUpCommandLine(base::CommandLine* command_line) override { |
412 ExtensionBrowserTest::SetUpCommandLine(command_line); | 412 ExtensionBrowserTest::SetUpCommandLine(command_line); |
413 } | 413 } |
414 }; | 414 }; |
415 | 415 |
416 IN_PROC_BROWSER_TEST_F(FlagOffActiveScriptControllerBrowserTest, | 416 IN_PROC_BROWSER_TEST_F(FlagOffActiveScriptControllerBrowserTest, |
417 ScriptsExecuteWhenFlagAbsent) { | 417 ScriptsExecuteWhenFlagAbsent) { |
418 const char* kExtensionNames[] = { | 418 const char* kExtensionNames[] = { |
419 "content_scripts_all_hosts", | 419 "content_scripts_all_hosts", |
420 "inject_scripts_all_hosts", | 420 "inject_scripts_all_hosts", |
421 }; | 421 }; |
(...skipping 14 matching lines...) Expand all Loading... |
436 | 436 |
437 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 437 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
438 ui_test_utils::NavigateToURL( | 438 ui_test_utils::NavigateToURL( |
439 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); | 439 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); |
440 | 440 |
441 for (size_t i = 0u; i < arraysize(testers); ++i) | 441 for (size_t i = 0u; i < arraysize(testers); ++i) |
442 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; | 442 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; |
443 } | 443 } |
444 | 444 |
445 } // namespace extensions | 445 } // namespace extensions |
OLD | NEW |