| 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/browser/ui/browser_tabstrip.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/test/browser_test_utils.h" |
| 26 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
| 27 | 28 |
| 28 // This file contains high-level startup tests for the extensions system. We've | 29 // This file contains high-level startup tests for the extensions system. We've |
| 29 // had many silly bugs where command line flags did not get propagated correctly | 30 // had many silly bugs where command line flags did not get propagated correctly |
| 30 // into the services, so we didn't start correctly. | 31 // into the services, so we didn't start correctly. |
| 31 | 32 |
| 32 class ExtensionStartupTestBase : public InProcessBrowserTest { | 33 class ExtensionStartupTestBase : public InProcessBrowserTest { |
| 33 public: | 34 public: |
| 34 ExtensionStartupTestBase() : enable_extensions_(false) { | 35 ExtensionStartupTestBase() : enable_extensions_(false) { |
| 35 num_expected_extensions_ = 3; | 36 num_expected_extensions_ = 3; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void TestInjection(bool expect_css, bool expect_script) { | 111 void TestInjection(bool expect_css, bool expect_script) { |
| 111 // Load a page affected by the content script and test to see the effect. | 112 // Load a page affected by the content script and test to see the effect. |
| 112 FilePath test_file; | 113 FilePath test_file; |
| 113 PathService::Get(chrome::DIR_TEST_DATA, &test_file); | 114 PathService::Get(chrome::DIR_TEST_DATA, &test_file); |
| 114 test_file = test_file.AppendASCII("extensions") | 115 test_file = test_file.AppendASCII("extensions") |
| 115 .AppendASCII("test_file.html"); | 116 .AppendASCII("test_file.html"); |
| 116 | 117 |
| 117 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); | 118 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); |
| 118 | 119 |
| 119 bool result = false; | 120 bool result = false; |
| 120 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 121 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 121 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", | 122 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 122 L"window.domAutomationController.send(" | 123 L"window.domAutomationController.send(" |
| 123 L"document.defaultView.getComputedStyle(document.body, null)." | 124 L"document.defaultView.getComputedStyle(document.body, null)." |
| 124 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')", | 125 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')", |
| 125 &result)); | 126 &result)); |
| 126 EXPECT_EQ(expect_css, result); | 127 EXPECT_EQ(expect_css, result); |
| 127 | 128 |
| 128 result = false; | 129 result = false; |
| 129 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 130 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 130 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", | 131 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 131 L"window.domAutomationController.send(document.title == 'Modified')", | 132 L"window.domAutomationController.send(document.title == 'Modified')", |
| 132 &result)); | 133 &result)); |
| 133 EXPECT_EQ(expect_script, result); | 134 EXPECT_EQ(expect_script, result); |
| 134 } | 135 } |
| 135 | 136 |
| 136 FilePath preferences_file_; | 137 FilePath preferences_file_; |
| 137 FilePath extensions_dir_; | 138 FilePath extensions_dir_; |
| 138 FilePath user_scripts_dir_; | 139 FilePath user_scripts_dir_; |
| 139 bool enable_extensions_; | 140 bool enable_extensions_; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 .AppendASCII("extensions") | 261 .AppendASCII("extensions") |
| 261 .AppendASCII("app2"); | 262 .AppendASCII("app2"); |
| 262 load_extensions_.push_back(fourth_extension_path.value()); | 263 load_extensions_.push_back(fourth_extension_path.value()); |
| 263 } | 264 } |
| 264 }; | 265 }; |
| 265 | 266 |
| 266 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { | 267 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
| 267 WaitForServicesToStart(4, true); | 268 WaitForServicesToStart(4, true); |
| 268 TestInjection(true, true); | 269 TestInjection(true, true); |
| 269 } | 270 } |
| OLD | NEW |