OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 NotificationService::AllSources()); | 124 NotificationService::AllSources()); |
125 ui_test_utils::RunMessageLoop(); | 125 ui_test_utils::RunMessageLoop(); |
126 registrar_.Remove(this, NotificationType::USER_SCRIPTS_UPDATED, | 126 registrar_.Remove(this, NotificationType::USER_SCRIPTS_UPDATED, |
127 NotificationService::AllSources()); | 127 NotificationService::AllSources()); |
128 } | 128 } |
129 ASSERT_TRUE(master->ScriptsReady()); | 129 ASSERT_TRUE(master->ScriptsReady()); |
130 } | 130 } |
131 | 131 |
132 void TestInjection(bool expect_css, bool expect_script) { | 132 void TestInjection(bool expect_css, bool expect_script) { |
133 // Load a page affected by the content script and test to see the effect. | 133 // Load a page affected by the content script and test to see the effect. |
134 FilePath test_file; | 134 HTTPTestServer* server = StartHTTPServer(); |
135 PathService::Get(chrome::DIR_TEST_DATA, &test_file); | 135 GURL url = server->TestServerPage("file/extensions/test_file.html"); |
136 test_file = test_file.AppendASCII("extensions") | 136 ui_test_utils::NavigateToURL(browser(), url); |
137 .AppendASCII("test_file.html"); | |
138 | |
139 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); | |
140 | 137 |
141 bool result = false; | 138 bool result = false; |
142 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 139 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
143 browser()->GetSelectedTabContents()->render_view_host(), L"", | 140 browser()->GetSelectedTabContents()->render_view_host(), L"", |
144 L"window.domAutomationController.send(" | 141 L"window.domAutomationController.send(" |
145 L"document.defaultView.getComputedStyle(document.body, null)." | 142 L"document.defaultView.getComputedStyle(document.body, null)." |
146 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')", | 143 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')", |
147 &result); | 144 &result); |
148 EXPECT_EQ(expect_css, result); | 145 EXPECT_EQ(expect_css, result); |
149 | 146 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 225 |
229 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | 226 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
230 | 227 |
231 bool result = false; | 228 bool result = false; |
232 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 229 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
233 browser()->GetSelectedTabContents()->render_view_host(), L"", | 230 browser()->GetSelectedTabContents()->render_view_host(), L"", |
234 L"window.domAutomationController.send(document.title == 'Modified')", | 231 L"window.domAutomationController.send(document.title == 'Modified')", |
235 &result); | 232 &result); |
236 EXPECT_FALSE(result); | 233 EXPECT_FALSE(result); |
237 } | 234 } |
OLD | NEW |