OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "content/browser/tab_contents/tab_contents.h" | 7 #include "content/browser/tab_contents/tab_contents.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/common/chrome_notification_types.h" |
9 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/test/ui_test_utils.h" | 11 #include "chrome/test/ui_test_utils.h" |
11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
12 #include "net/base/mock_host_resolver.h" | 13 #include "net/base/mock_host_resolver.h" |
13 | 14 |
14 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { | 15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { |
15 ASSERT_TRUE(StartTestServer()); | 16 ASSERT_TRUE(StartTestServer()); |
16 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; | 17 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; |
17 } | 18 } |
18 | 19 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptViewSource) { | 63 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptViewSource) { |
63 ASSERT_TRUE(StartTestServer()); | 64 ASSERT_TRUE(StartTestServer()); |
64 ASSERT_TRUE(RunExtensionTest("content_scripts/view_source")) << message_; | 65 ASSERT_TRUE(RunExtensionTest("content_scripts/view_source")) << message_; |
65 } | 66 } |
66 | 67 |
67 IN_PROC_BROWSER_TEST_F( | 68 IN_PROC_BROWSER_TEST_F( |
68 ExtensionApiTest, ContentScriptStylesInjectedIntoExistingRenderers) { | 69 ExtensionApiTest, ContentScriptStylesInjectedIntoExistingRenderers) { |
69 ASSERT_TRUE(StartTestServer()); | 70 ASSERT_TRUE(StartTestServer()); |
70 | 71 |
71 ui_test_utils::WindowedNotificationObserver signal( | 72 ui_test_utils::WindowedNotificationObserver signal( |
72 NotificationType::USER_SCRIPTS_UPDATED, | 73 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, |
73 Source<Profile>(browser()->profile())); | 74 Source<Profile>(browser()->profile())); |
74 | 75 |
75 // Start with a renderer already open at a URL. | 76 // Start with a renderer already open at a URL. |
76 GURL url(test_server()->GetURL("file/extensions/test_file.html")); | 77 GURL url(test_server()->GetURL("file/extensions/test_file.html")); |
77 ui_test_utils::NavigateToURL(browser(), url); | 78 ui_test_utils::NavigateToURL(browser(), url); |
78 | 79 |
79 LoadExtension( | 80 LoadExtension( |
80 test_data_dir_.AppendASCII("content_scripts/existing_renderers")); | 81 test_data_dir_.AppendASCII("content_scripts/existing_renderers")); |
81 | 82 |
82 signal.Wait(); | 83 signal.Wait(); |
83 | 84 |
84 // And check that its styles were affected by the styles that just got loaded. | 85 // And check that its styles were affected by the styles that just got loaded. |
85 bool styles_injected; | 86 bool styles_injected; |
86 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 87 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
87 browser()->GetSelectedTabContents()->render_view_host(), L"", | 88 browser()->GetSelectedTabContents()->render_view_host(), L"", |
88 L"window.domAutomationController.send(" | 89 L"window.domAutomationController.send(" |
89 L"document.defaultView.getComputedStyle(document.body, null)." | 90 L"document.defaultView.getComputedStyle(document.body, null)." |
90 L"getPropertyValue('background-color') == 'rgb(255, 0, 0)')", | 91 L"getPropertyValue('background-color') == 'rgb(255, 0, 0)')", |
91 &styles_injected)); | 92 &styles_injected)); |
92 ASSERT_TRUE(styles_injected); | 93 ASSERT_TRUE(styles_injected); |
93 } | 94 } |
OLD | NEW |