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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/extensions/api/permissions/permissions_api.h" | 6 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 #include "net/base/mock_host_resolver.h" | 17 #include "net/base/mock_host_resolver.h" |
17 | 18 |
18 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { | 19 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { |
19 ASSERT_TRUE(StartTestServer()); | 20 ASSERT_TRUE(StartTestServer()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ui_test_utils::NavigateToURL(browser(), url); | 97 ui_test_utils::NavigateToURL(browser(), url); |
97 | 98 |
98 LoadExtension( | 99 LoadExtension( |
99 test_data_dir_.AppendASCII("content_scripts/existing_renderers")); | 100 test_data_dir_.AppendASCII("content_scripts/existing_renderers")); |
100 | 101 |
101 signal.Wait(); | 102 signal.Wait(); |
102 | 103 |
103 // And check that its styles were affected by the styles that just got loaded. | 104 // And check that its styles were affected by the styles that just got loaded. |
104 bool styles_injected; | 105 bool styles_injected; |
105 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 106 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
106 browser()->GetActiveWebContents()->GetRenderViewHost(), L"", | 107 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
107 L"window.domAutomationController.send(" | 108 L"window.domAutomationController.send(" |
108 L"document.defaultView.getComputedStyle(document.body, null)." | 109 L"document.defaultView.getComputedStyle(document.body, null)." |
109 L"getPropertyValue('background-color') == 'rgb(255, 0, 0)')", | 110 L"getPropertyValue('background-color') == 'rgb(255, 0, 0)')", |
110 &styles_injected)); | 111 &styles_injected)); |
111 ASSERT_TRUE(styles_injected); | 112 ASSERT_TRUE(styles_injected); |
112 } | 113 } |
113 | 114 |
114 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptCSSLocalization) { | 115 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptCSSLocalization) { |
115 ASSERT_TRUE(StartTestServer()); | 116 ASSERT_TRUE(StartTestServer()); |
116 ASSERT_TRUE(RunExtensionTest("content_scripts/css_l10n")) << message_; | 117 ASSERT_TRUE(RunExtensionTest("content_scripts/css_l10n")) << message_; |
(...skipping 25 matching lines...) Expand all Loading... |
142 EXPECT_TRUE(catcher.GetNextResult()); | 143 EXPECT_TRUE(catcher.GetNextResult()); |
143 } | 144 } |
144 | 145 |
145 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptPermissionsApi) { | 146 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptPermissionsApi) { |
146 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); | 147 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); |
147 RequestPermissionsFunction::SetAutoConfirmForTests(true); | 148 RequestPermissionsFunction::SetAutoConfirmForTests(true); |
148 host_resolver()->AddRule("*.com", "127.0.0.1"); | 149 host_resolver()->AddRule("*.com", "127.0.0.1"); |
149 ASSERT_TRUE(StartTestServer()); | 150 ASSERT_TRUE(StartTestServer()); |
150 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; | 151 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; |
151 } | 152 } |
OLD | NEW |