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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/user_script_master.h" | 13 #include "chrome/browser/extensions/user_script_master.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
21 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
25 | 26 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Load a page affected by the content script and test to see the effect. | 111 // Load a page affected by the content script and test to see the effect. |
111 FilePath test_file; | 112 FilePath test_file; |
112 PathService::Get(chrome::DIR_TEST_DATA, &test_file); | 113 PathService::Get(chrome::DIR_TEST_DATA, &test_file); |
113 test_file = test_file.AppendASCII("extensions") | 114 test_file = test_file.AppendASCII("extensions") |
114 .AppendASCII("test_file.html"); | 115 .AppendASCII("test_file.html"); |
115 | 116 |
116 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); | 117 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); |
117 | 118 |
118 bool result = false; | 119 bool result = false; |
119 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 120 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
120 browser()->GetActiveWebContents()->GetRenderViewHost(), L"", | 121 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
121 L"window.domAutomationController.send(" | 122 L"window.domAutomationController.send(" |
122 L"document.defaultView.getComputedStyle(document.body, null)." | 123 L"document.defaultView.getComputedStyle(document.body, null)." |
123 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')", | 124 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')", |
124 &result)); | 125 &result)); |
125 EXPECT_EQ(expect_css, result); | 126 EXPECT_EQ(expect_css, result); |
126 | 127 |
127 result = false; | 128 result = false; |
128 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 129 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
129 browser()->GetActiveWebContents()->GetRenderViewHost(), L"", | 130 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
130 L"window.domAutomationController.send(document.title == 'Modified')", | 131 L"window.domAutomationController.send(document.title == 'Modified')", |
131 &result)); | 132 &result)); |
132 EXPECT_EQ(expect_script, result); | 133 EXPECT_EQ(expect_script, result); |
133 } | 134 } |
134 | 135 |
135 FilePath preferences_file_; | 136 FilePath preferences_file_; |
136 FilePath extensions_dir_; | 137 FilePath extensions_dir_; |
137 FilePath user_scripts_dir_; | 138 FilePath user_scripts_dir_; |
138 bool enable_extensions_; | 139 bool enable_extensions_; |
139 // Extensions to load from the command line. | 140 // Extensions to load from the command line. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 .AppendASCII("extensions") | 260 .AppendASCII("extensions") |
260 .AppendASCII("app2"); | 261 .AppendASCII("app2"); |
261 load_extensions_.push_back(fourth_extension_path.value()); | 262 load_extensions_.push_back(fourth_extension_path.value()); |
262 } | 263 } |
263 }; | 264 }; |
264 | 265 |
265 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { | 266 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
266 WaitForServicesToStart(4, true); | 267 WaitForServicesToStart(4, true); |
267 TestInjection(true, true); | 268 TestInjection(true, true); |
268 } | 269 } |
OLD | NEW |