Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/browser/extensions/extension_browsertests_misc.cc

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: interactive_ui_tests Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/autoupdate_interceptor.h" 8 #include "chrome/browser/extensions/autoupdate_interceptor.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
(...skipping 19 matching lines...) Expand all
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
32 #include "net/test/test_server.h" 32 #include "net/test/test_server.h"
33 #include "webkit/glue/webpreferences.h" 33 #include "webkit/glue/webpreferences.h"
34 34
35 #if defined(TOOLKIT_VIEWS) 35 #if defined(TOOLKIT_VIEWS)
36 #include "chrome/browser/ui/views/frame/browser_view.h" 36 #include "chrome/browser/ui/views/frame/browser_view.h"
37 #endif 37 #endif
38 38
39 using content::NavigationController; 39 using content::NavigationController;
40 using content::RenderViewHost;
40 using content::WebContents; 41 using content::WebContents;
41 42
42 const std::string kSubscribePage = "/subscribe.html"; 43 const std::string kSubscribePage = "/subscribe.html";
43 const std::string kFeedPage = "files/feeds/feed.html"; 44 const std::string kFeedPage = "files/feeds/feed.html";
44 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html"; 45 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html";
45 const std::string kNoFeedPage = "files/feeds/no_feed.html"; 46 const std::string kNoFeedPage = "files/feeds/no_feed.html";
46 const std::string kValidFeed0 = "files/feeds/feed_script.xml"; 47 const std::string kValidFeed0 = "files/feeds/feed_script.xml";
47 const std::string kValidFeed1 = "files/feeds/feed1.xml"; 48 const std::string kValidFeed1 = "files/feeds/feed1.xml";
48 const std::string kValidFeed2 = "files/feeds/feed2.xml"; 49 const std::string kValidFeed2 = "files/feeds/feed2.xml";
49 const std::string kValidFeed3 = "files/feeds/feed3.xml"; 50 const std::string kValidFeed3 = "files/feeds/feed3.xml";
50 const std::string kValidFeed4 = "files/feeds/feed4.xml"; 51 const std::string kValidFeed4 = "files/feeds/feed4.xml";
51 const std::string kValidFeed5 = "files/feeds/feed5.xml"; 52 const std::string kValidFeed5 = "files/feeds/feed5.xml";
52 const std::string kValidFeed6 = "files/feeds/feed6.xml"; 53 const std::string kValidFeed6 = "files/feeds/feed6.xml";
53 const std::string kValidFeedNoLinks = "files/feeds/feed_nolinks.xml"; 54 const std::string kValidFeedNoLinks = "files/feeds/feed_nolinks.xml";
54 const std::string kInvalidFeed1 = "files/feeds/feed_invalid1.xml"; 55 const std::string kInvalidFeed1 = "files/feeds/feed_invalid1.xml";
55 const std::string kInvalidFeed2 = "files/feeds/feed_invalid2.xml"; 56 const std::string kInvalidFeed2 = "files/feeds/feed_invalid2.xml";
56 const std::string kLocalization = 57 const std::string kLocalization =
57 "files/extensions/browsertest/title_localized_pa/simple.html"; 58 "files/extensions/browsertest/title_localized_pa/simple.html";
58 // We need a triple encoded string to prove that we are not decoding twice in 59 // We need a triple encoded string to prove that we are not decoding twice in
59 // subscribe.js because one layer is also stripped off when subscribe.js passes 60 // subscribe.js because one layer is also stripped off when subscribe.js passes
60 // it to the XMLHttpRequest object. 61 // it to the XMLHttpRequest object.
61 const std::string kFeedTripleEncoded = "files/feeds/url%25255Fdecoding.html"; 62 const std::string kFeedTripleEncoded = "files/feeds/url%25255Fdecoding.html";
62 const std::string kHashPageA = 63 const std::string kHashPageA =
63 "files/extensions/api_test/page_action/hash_change/test_page_A.html"; 64 "files/extensions/api_test/page_action/hash_change/test_page_A.html";
64 const std::string kHashPageAHash = kHashPageA + "#asdf"; 65 const std::string kHashPageAHash = kHashPageA + "#asdf";
65 const std::string kHashPageB = 66 const std::string kHashPageB =
66 "files/extensions/api_test/page_action/hash_change/test_page_B.html"; 67 "files/extensions/api_test/page_action/hash_change/test_page_B.html";
67 68
68 // Looks for an ExtensionHost whose URL has the given path component (including 69 // Looks for a RenderViewHost whose URL has the given path component (including
69 // leading slash). Also verifies that the expected number of hosts are loaded. 70 // leading slash). Also verifies that the expected number of hosts are loaded.
70 static ExtensionHost* FindHostWithPath(ExtensionProcessManager* manager, 71 static RenderViewHost* FindHostWithPath(ExtensionProcessManager* manager,
71 const std::string& path, 72 const std::string& path,
72 int expected_hosts) { 73 int expected_hosts) {
73 ExtensionHost* host = NULL; 74 RenderViewHost* host = NULL;
74 int num_hosts = 0; 75 int num_hosts = 0;
75 for (ExtensionProcessManager::const_iterator iter = manager->begin(); 76 ExtensionProcessManager::ContentsSet all_contents = manager->GetAllContents();
76 iter != manager->end(); ++iter) { 77 for (ExtensionProcessManager::ContentsSet::const_iterator iter =
78 all_contents.begin();
79 iter != all_contents.end(); ++iter) {
77 if ((*iter)->GetURL().path() == path) { 80 if ((*iter)->GetURL().path() == path) {
78 EXPECT_FALSE(host); 81 EXPECT_FALSE(host);
79 host = *iter; 82 host = (*iter)->GetRenderViewHost();
80 } 83 }
81 num_hosts++; 84 num_hosts++;
82 } 85 }
83 EXPECT_EQ(expected_hosts, num_hosts); 86 EXPECT_EQ(expected_hosts, num_hosts);
84 return host; 87 return host;
85 } 88 }
86 89
87 // Tests that we can load extension pages into the tab area and they can call 90 // Tests that we can load extension pages into the tab area and they can call
88 // extension APIs. 91 // extension APIs.
89 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebContents) { 92 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebContents) {
(...skipping 28 matching lines...) Expand all
118 // Tests that GPU-related WebKit preferences are set for extension background 121 // Tests that GPU-related WebKit preferences are set for extension background
119 // pages. See http://crbug.com/64512. 122 // pages. See http://crbug.com/64512.
120 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) { 123 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) {
121 ASSERT_TRUE(LoadExtension( 124 ASSERT_TRUE(LoadExtension(
122 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 125 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
123 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 126 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
124 .AppendASCII("1.0.0.0"))); 127 .AppendASCII("1.0.0.0")));
125 128
126 ExtensionProcessManager* manager = 129 ExtensionProcessManager* manager =
127 browser()->profile()->GetExtensionProcessManager(); 130 browser()->profile()->GetExtensionProcessManager();
128 ExtensionHost* host = FindHostWithPath(manager, "/backgroundpage.html", 1); 131 RenderViewHost* host = FindHostWithPath(manager, "/backgroundpage.html", 1);
129 WebPreferences prefs = 132 WebPreferences prefs = host->GetDelegate()->GetWebkitPrefs();
130 host->render_view_host()->GetDelegate()->GetWebkitPrefs();
131 ASSERT_TRUE(prefs.experimental_webgl_enabled); 133 ASSERT_TRUE(prefs.experimental_webgl_enabled);
132 ASSERT_TRUE(prefs.accelerated_compositing_enabled); 134 ASSERT_TRUE(prefs.accelerated_compositing_enabled);
133 ASSERT_TRUE(prefs.accelerated_2d_canvas_enabled); 135 ASSERT_TRUE(prefs.accelerated_2d_canvas_enabled);
134 } 136 }
135 137
136 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionCrash25562) { 138 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionCrash25562) {
137 ASSERT_TRUE(test_server()->Start()); 139 ASSERT_TRUE(test_server()->Start());
138 140
139 CommandLine::ForCurrentProcess()->AppendSwitch( 141 CommandLine::ForCurrentProcess()->AppendSwitch(
140 switches::kAllowLegacyExtensionManifests); 142 switches::kAllowLegacyExtensionManifests);
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 683
682 // Tests that an error raised during an async function still fires 684 // Tests that an error raised during an async function still fires
683 // the callback, but sets chrome.extension.lastError. 685 // the callback, but sets chrome.extension.lastError.
684 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) { 686 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) {
685 ASSERT_TRUE(LoadExtension( 687 ASSERT_TRUE(LoadExtension(
686 test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error"))); 688 test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error")));
687 689
688 // Get the ExtensionHost that is hosting our background page. 690 // Get the ExtensionHost that is hosting our background page.
689 ExtensionProcessManager* manager = 691 ExtensionProcessManager* manager =
690 browser()->profile()->GetExtensionProcessManager(); 692 browser()->profile()->GetExtensionProcessManager();
691 ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1); 693 RenderViewHost* host = FindHostWithPath(manager, "/bg.html", 1);
692 694
693 bool result = false; 695 bool result = false;
694 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 696 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
695 host->render_view_host(), L"", L"testLastError()", &result)); 697 host, L"", L"testLastError()", &result));
696 EXPECT_TRUE(result); 698 EXPECT_TRUE(result);
697 } 699 }
698 700
699 // Helper function for common code shared by the 3 WindowOpen tests below. 701 // Helper function for common code shared by the 3 WindowOpen tests below.
700 static void WindowOpenHelper(Browser* browser, const GURL& start_url, 702 static void WindowOpenHelper(Browser* browser, const GURL& start_url,
701 const std::string& newtab_url, 703 const std::string& newtab_url,
702 WebContents** newtab_result) { 704 WebContents** newtab_result) {
703 ui_test_utils::NavigateToURL(browser, start_url); 705 ui_test_utils::NavigateToURL(browser, start_url);
704 706
705 ui_test_utils::WindowedNotificationObserver observer( 707 ui_test_utils::WindowedNotificationObserver observer(
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 926
925 EXPECT_EQ(extension->GetResourceURL("options.html"), 927 EXPECT_EQ(extension->GetResourceURL("options.html"),
926 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL()); 928 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL());
927 } 929 }
928 930
929 //============================================================================== 931 //==============================================================================
930 // STOP! Please do not add any more random-ass tests here. Create new files for 932 // STOP! Please do not add any more random-ass tests here. Create new files for
931 // your tests grouped by functionality. Also, you should strongly consider using 933 // your tests grouped by functionality. Also, you should strongly consider using
932 // ExtensionAPITest if possible. 934 // ExtensionAPITest if possible.
933 //============================================================================== 935 //==============================================================================
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698