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