| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return content::ExecuteScript(web_contents, "1 == 1;"); | 66 return content::ExecuteScript(web_contents, "1 == 1;"); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 class ActiveScriptControllerBrowserTest : public ExtensionBrowserTest { | 71 class ActiveScriptControllerBrowserTest : public ExtensionBrowserTest { |
| 72 public: | 72 public: |
| 73 ActiveScriptControllerBrowserTest() {} | 73 ActiveScriptControllerBrowserTest() {} |
| 74 | 74 |
| 75 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; | 75 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; |
| 76 virtual void CleanUpOnMainThread() OVERRIDE; | 76 virtual void TearDownOnMainThread() OVERRIDE; |
| 77 | 77 |
| 78 // Returns an extension with the given |host_type| and |injection_type|. If | 78 // Returns an extension with the given |host_type| and |injection_type|. If |
| 79 // one already exists, the existing extension will be returned. Othewrwise, | 79 // one already exists, the existing extension will be returned. Othewrwise, |
| 80 // one will be created. | 80 // one will be created. |
| 81 // This could potentially return NULL if LoadExtension() fails. | 81 // This could potentially return NULL if LoadExtension() fails. |
| 82 const Extension* CreateExtension(HostType host_type, | 82 const Extension* CreateExtension(HostType host_type, |
| 83 InjectionType injection_type); | 83 InjectionType injection_type); |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 ScopedVector<TestExtensionDir> test_extension_dirs_; | 86 ScopedVector<TestExtensionDir> test_extension_dirs_; |
| 87 std::vector<const Extension*> extensions_; | 87 std::vector<const Extension*> extensions_; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 void ActiveScriptControllerBrowserTest::SetUpCommandLine( | 90 void ActiveScriptControllerBrowserTest::SetUpCommandLine( |
| 91 base::CommandLine* command_line) { | 91 base::CommandLine* command_line) { |
| 92 ExtensionBrowserTest::SetUpCommandLine(command_line); | 92 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 93 // We append the actual switch to the commandline because it needs to be | 93 // We append the actual switch to the commandline because it needs to be |
| 94 // passed over to the renderer, which a FeatureSwitch::ScopedOverride will | 94 // passed over to the renderer, which a FeatureSwitch::ScopedOverride will |
| 95 // not do. | 95 // not do. |
| 96 command_line->AppendSwitch(switches::kEnableScriptsRequireAction); | 96 command_line->AppendSwitch(switches::kEnableScriptsRequireAction); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void ActiveScriptControllerBrowserTest::CleanUpOnMainThread() { | 99 void ActiveScriptControllerBrowserTest::TearDownOnMainThread() { |
| 100 test_extension_dirs_.clear(); | 100 test_extension_dirs_.clear(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 const Extension* ActiveScriptControllerBrowserTest::CreateExtension( | 103 const Extension* ActiveScriptControllerBrowserTest::CreateExtension( |
| 104 HostType host_type, InjectionType injection_type) { | 104 HostType host_type, InjectionType injection_type) { |
| 105 std::string name = | 105 std::string name = |
| 106 base::StringPrintf( | 106 base::StringPrintf( |
| 107 "%s %s", | 107 "%s %s", |
| 108 injection_type == CONTENT_SCRIPT ? | 108 injection_type == CONTENT_SCRIPT ? |
| 109 "content_script" : "execute_script", | 109 "content_script" : "execute_script", |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 452 |
| 453 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 453 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 454 ui_test_utils::NavigateToURL( | 454 ui_test_utils::NavigateToURL( |
| 455 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); | 455 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); |
| 456 | 456 |
| 457 for (size_t i = 0u; i < arraysize(testers); ++i) | 457 for (size_t i = 0u; i < arraysize(testers); ++i) |
| 458 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; | 458 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace extensions | 461 } // namespace extensions |
| OLD | NEW |