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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_apitest.cc

Issue 12066003: Remove TabStripModel wrapper use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 7 years, 10 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 | Annotate | Revision Log
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/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 6 #include "chrome/browser/extensions/api/web_request/web_request_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/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/extension_test_message_listener.h" 10 #include "chrome/browser/extensions/extension_test_message_listener.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/browser/ui/login/login_prompt.h" 13 #include "chrome/browser/ui/login/login_prompt.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/features/feature.h" 17 #include "chrome/common/extensions/features/feature.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/test/browser_test_utils.h" 23 #include "content/public/test/browser_test_utils.h"
24 #include "net/base/mock_host_resolver.h" 24 #include "net/base/mock_host_resolver.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestBlocking) { 107 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestBlocking) {
108 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << 108 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) <<
109 message_; 109 message_;
110 } 110 }
111 111
112 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) { 112 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) {
113 // Wait for the extension to set itself up and return control to us. 113 // Wait for the extension to set itself up and return control to us.
114 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html")) 114 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html"))
115 << message_; 115 << message_;
116 116
117 WebContents* tab = chrome::GetActiveWebContents(browser()); 117 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
118 content::WaitForLoadStop(tab); 118 content::WaitForLoadStop(tab);
119 119
120 ResultCatcher catcher; 120 ResultCatcher catcher;
121 121
122 ExtensionService* service = extensions::ExtensionSystem::Get( 122 ExtensionService* service = extensions::ExtensionSystem::Get(
123 browser()->profile())->extension_service(); 123 browser()->profile())->extension_service();
124 const extensions::Extension* extension = 124 const extensions::Extension* extension =
125 service->GetExtensionById(last_loaded_extension_id_, false); 125 service->GetExtensionById(last_loaded_extension_id_, false);
126 GURL url = extension->GetResourceURL("newTab/a.html"); 126 GURL url = extension->GetResourceURL("newTab/a.html");
127 127
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 // Test that navigation in regular window is properly redirected. 184 // Test that navigation in regular window is properly redirected.
185 EXPECT_TRUE(listener.WaitUntilSatisfied()); 185 EXPECT_TRUE(listener.WaitUntilSatisfied());
186 186
187 // This navigation should be redirected. 187 // This navigation should be redirected.
188 ui_test_utils::NavigateToURL( 188 ui_test_utils::NavigateToURL(
189 browser(), 189 browser(),
190 test_server()->GetURL("files/extensions/test_file.html")); 190 test_server()->GetURL("files/extensions/test_file.html"));
191 191
192 std::string body; 192 std::string body;
193 WebContents* tab = chrome::GetActiveWebContents(browser()); 193 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
194 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 194 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
195 tab, 195 tab,
196 "window.domAutomationController.send(document.body.textContent)", 196 "window.domAutomationController.send(document.body.textContent)",
197 &body)); 197 &body));
198 EXPECT_EQ(expected_content_regular_window, body); 198 EXPECT_EQ(expected_content_regular_window, body);
199 199
200 // Test that navigation in OTR window is properly redirected. 200 // Test that navigation in OTR window is properly redirected.
201 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( 201 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
202 browser()->profile(), GURL("about:blank")); 202 browser()->profile(), GURL("about:blank"));
203 203
204 if (wait_for_extension_loaded_in_incognito) 204 if (wait_for_extension_loaded_in_incognito)
205 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); 205 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied());
206 206
207 // This navigation should be redirected if 207 // This navigation should be redirected if
208 // load_extension_with_incognito_permission is true. 208 // load_extension_with_incognito_permission is true.
209 ui_test_utils::NavigateToURL( 209 ui_test_utils::NavigateToURL(
210 otr_browser, 210 otr_browser,
211 test_server()->GetURL("files/extensions/test_file.html")); 211 test_server()->GetURL("files/extensions/test_file.html"));
212 212
213 body.clear(); 213 body.clear();
214 WebContents* otr_tab = chrome::GetActiveWebContents(otr_browser); 214 WebContents* otr_tab = otr_browser->tab_strip_model()->GetActiveWebContents();
215 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 215 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
216 otr_tab, 216 otr_tab,
217 "window.domAutomationController.send(document.body.textContent)", 217 "window.domAutomationController.send(document.body.textContent)",
218 &body)); 218 &body));
219 EXPECT_EQ(exptected_content_incognito_window, body); 219 EXPECT_EQ(exptected_content_incognito_window, body);
220 } 220 }
221 221
222 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, 222 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
223 WebRequestDeclarativePermissionSpanning1) { 223 WebRequestDeclarativePermissionSpanning1) {
224 // Test spanning with incognito permission. 224 // Test spanning with incognito permission.
(...skipping 28 matching lines...) Expand all
253 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, PostData2) { 253 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, PostData2) {
254 // Test HTML form POST data access with the multipart and plaintext encoding. 254 // Test HTML form POST data access with the multipart and plaintext encoding.
255 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_post2.html")) << 255 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_post2.html")) <<
256 message_; 256 message_;
257 } 257 }
258 258
259 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, 259 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
260 DeclarativeSendMessage) { 260 DeclarativeSendMessage) {
261 ASSERT_TRUE(RunExtensionTest("webrequest_sendmessage")) << message_; 261 ASSERT_TRUE(RunExtensionTest("webrequest_sendmessage")) << message_;
262 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698