| 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/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/extensions/test_extension_dir.h" | 9 #include "chrome/browser/extensions/test_extension_dir.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 std::string background_src = base::StringPrintf( | 170 std::string background_src = base::StringPrintf( |
| 171 kBackgroundScriptSource, | 171 kBackgroundScriptSource, |
| 172 kScriptMatchers[script_matcher]); | 172 kScriptMatchers[script_matcher]); |
| 173 | 173 |
| 174 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); | 174 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); |
| 175 dir->WriteManifest(manifest); | 175 dir->WriteManifest(manifest); |
| 176 dir->WriteFile(FILE_PATH_LITERAL("background.js"), background_src); | 176 dir->WriteFile(FILE_PATH_LITERAL("background.js"), background_src); |
| 177 dir->WriteFile(FILE_PATH_LITERAL("script.js"), | 177 dir->WriteFile(FILE_PATH_LITERAL("script.js"), |
| 178 kContentScriptSource); | 178 kContentScriptSource); |
| 179 | 179 |
| 180 const Extension* extension = LoadExtension(dir->unpacked_path()); | 180 const Extension* extension = LoadExtension(dir->UnpackedPath()); |
| 181 if (!extension) | 181 if (!extension) |
| 182 return testing::AssertionFailure() << "Failed to load extension."; | 182 return testing::AssertionFailure() << "Failed to load extension."; |
| 183 | 183 |
| 184 test_extension_dir_.reset(dir.release()); | 184 test_extension_dir_.reset(dir.release()); |
| 185 extension_ = extension; | 185 extension_ = extension; |
| 186 | 186 |
| 187 // Wait for rules to be setup before navigating to trigger script injection. | 187 // Wait for rules to be setup before navigating to trigger script injection. |
| 188 injection_setup_listener.WaitUntilSatisfied(); | 188 injection_setup_listener.WaitUntilSatisfied(); |
| 189 | 189 |
| 190 return testing::AssertionSuccess(); | 190 return testing::AssertionSuccess(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 215 EXPECT_TRUE(RunTest(PARTICULAR, NOWHERE, false)); | 215 EXPECT_TRUE(RunTest(PARTICULAR, NOWHERE, false)); |
| 216 | 216 |
| 217 // TODO(markdittmer): Add more tests: | 217 // TODO(markdittmer): Add more tests: |
| 218 // - Inject script with multiple files | 218 // - Inject script with multiple files |
| 219 // - Inject multiple scripts | 219 // - Inject multiple scripts |
| 220 // - Match on CSS selector conditions | 220 // - Match on CSS selector conditions |
| 221 // - Match all frames in document containing frames | 221 // - Match all frames in document containing frames |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace extensions | 224 } // namespace extensions |
| OLD | NEW |