OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ref_counted.h" | 5 #include "base/ref_counted.h" |
6 #include "chrome/browser/browser.h" | 6 #include "chrome/browser/browser.h" |
7 #include "chrome/browser/browser_list.h" | 7 #include "chrome/browser/browser_list.h" |
8 #include "chrome/browser/renderer_host/render_view_host.h" | 8 #include "chrome/browser/renderer_host/render_view_host.h" |
9 #include "chrome/browser/extensions/autoupdate_interceptor.h" | 9 #include "chrome/browser/extensions/autoupdate_interceptor.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 11 #include "chrome/browser/extensions/extension_browsertest.h" |
11 #include "chrome/browser/extensions/extension_error_reporter.h" | 12 #include "chrome/browser/extensions/extension_error_reporter.h" |
12 #include "chrome/browser/extensions/extension_host.h" | 13 #include "chrome/browser/extensions/extension_host.h" |
13 #include "chrome/browser/extensions/extension_process_manager.h" | 14 #include "chrome/browser/extensions/extension_process_manager.h" |
14 #include "chrome/browser/extensions/extension_tabs_module.h" | 15 #include "chrome/browser/extensions/extension_tabs_module.h" |
15 #include "chrome/browser/extensions/extensions_service.h" | 16 #include "chrome/browser/extensions/extensions_service.h" |
16 #include "chrome/browser/extensions/extension_updater.h" | 17 #include "chrome/browser/extensions/extension_updater.h" |
17 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
18 #include "chrome/browser/renderer_host/site_instance.h" | 19 #include "chrome/browser/renderer_host/site_instance.h" |
19 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
20 #if defined(TOOLKIT_VIEWS) | 21 #if defined(TOOLKIT_VIEWS) |
21 #include "chrome/browser/views/extensions/extension_shelf.h" | 22 #include "chrome/browser/views/extensions/extension_shelf.h" |
22 #include "chrome/browser/views/frame/browser_view.h" | 23 #include "chrome/browser/views/frame/browser_view.h" |
23 #endif | 24 #endif |
24 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/extensions/extension_action.h" | 26 #include "chrome/common/extensions/extension_action.h" |
26 #include "chrome/common/notification_service.h" | 27 #include "chrome/common/notification_service.h" |
27 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
28 #include "chrome/test/ui_test_utils.h" | 29 #include "chrome/test/ui_test_utils.h" |
| 30 #include "net/base/mock_host_resolver.h" |
29 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
30 #include "net/test/test_server.h" | 32 #include "net/test/test_server.h" |
31 | 33 |
32 const std::string kSubscribePage = "/subscribe.html"; | 34 const std::string kSubscribePage = "/subscribe.html"; |
33 const std::string kFeedPage = "files/feeds/feed.html"; | 35 const std::string kFeedPage = "files/feeds/feed.html"; |
34 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html"; | 36 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html"; |
35 const std::string kNoFeedPage = "files/feeds/no_feed.html"; | 37 const std::string kNoFeedPage = "files/feeds/no_feed.html"; |
36 const std::string kValidFeed0 = "files/feeds/feed_script.xml"; | 38 const std::string kValidFeed0 = "files/feeds/feed_script.xml"; |
37 const std::string kValidFeed1 = "files/feeds/feed1.xml"; | 39 const std::string kValidFeed1 = "files/feeds/feed1.xml"; |
38 const std::string kValidFeed2 = "files/feeds/feed2.xml"; | 40 const std::string kValidFeed2 = "files/feeds/feed2.xml"; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 169 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
168 .AppendASCII("1.0.0.0"))); | 170 .AppendASCII("1.0.0.0"))); |
169 | 171 |
170 // There should now be two extension views and preferred height of the view | 172 // There should now be two extension views and preferred height of the view |
171 // should be non-zero. | 173 // should be non-zero. |
172 EXPECT_EQ(shelf->GetChildViewCount(), 2); | 174 EXPECT_EQ(shelf->GetChildViewCount(), 2); |
173 EXPECT_NE(shelf->GetPreferredSize().height(), 0); | 175 EXPECT_NE(shelf->GetPreferredSize().height(), 0); |
174 } | 176 } |
175 #endif // defined(TOOLKIT_VIEWS) | 177 #endif // defined(TOOLKIT_VIEWS) |
176 | 178 |
| 179 // Tests that extension resources can be loaded from origins which the |
| 180 // extension specifies in permissions but not from others. |
| 181 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, OriginPrivileges) { |
| 182 host_resolver()->AddRule("*", "127.0.0.1"); |
| 183 ASSERT_TRUE(StartHTTPServer()); |
| 184 ASSERT_TRUE(LoadExtension(test_data_dir_ |
| 185 .AppendASCII("origin_privileges").AppendASCII("extension"))); |
| 186 |
| 187 ui_test_utils::NavigateToURL(browser(), |
| 188 GURL("http://a.com:1337/files/extensions/origin_privileges/index.html")); |
| 189 std::string result; |
| 190 ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 191 browser()->GetSelectedTabContents()->render_view_host(), L"", |
| 192 L"window.domAutomationController.send(document.title)", |
| 193 &result); |
| 194 EXPECT_EQ(result, "Loaded"); |
| 195 |
| 196 ui_test_utils::NavigateToURL(browser(), |
| 197 GURL("http://b.com:1337/files/extensions/origin_privileges/index.html")); |
| 198 ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 199 browser()->GetSelectedTabContents()->render_view_host(), L"", |
| 200 L"window.domAutomationController.send(document.title)", |
| 201 &result); |
| 202 EXPECT_EQ(result, "Image failed to load"); |
| 203 } |
| 204 |
177 // Tests that we can load extension pages into the tab area and they can call | 205 // Tests that we can load extension pages into the tab area and they can call |
178 // extension APIs. | 206 // extension APIs. |
179 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TabContents) { | 207 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TabContents) { |
180 ASSERT_TRUE(LoadExtension( | 208 ASSERT_TRUE(LoadExtension( |
181 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 209 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
182 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 210 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
183 .AppendASCII("1.0.0.0"))); | 211 .AppendASCII("1.0.0.0"))); |
184 | 212 |
185 ui_test_utils::NavigateToURL( | 213 ui_test_utils::NavigateToURL( |
186 browser(), | 214 browser(), |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 | 861 |
834 // If the options page hasn't already come up, wait for it. | 862 // If the options page hasn't already come up, wait for it. |
835 if (tab_strip->count() == 1) { | 863 if (tab_strip->count() == 1) { |
836 ui_test_utils::WaitForNewTab(browser()); | 864 ui_test_utils::WaitForNewTab(browser()); |
837 } | 865 } |
838 ASSERT_EQ(2, tab_strip->count()); | 866 ASSERT_EQ(2, tab_strip->count()); |
839 | 867 |
840 EXPECT_EQ(extension->GetResourceURL("options.html"), | 868 EXPECT_EQ(extension->GetResourceURL("options.html"), |
841 tab_strip->GetTabContentsAt(1)->GetURL()); | 869 tab_strip->GetTabContentsAt(1)->GetURL()); |
842 } | 870 } |
OLD | NEW |