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