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

Side by Side Diff: chrome/browser/managed_mode/managed_mode_browsertest.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 "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
9 #include "chrome/browser/infobars/infobar.h" 9 #include "chrome/browser/infobars/infobar.h"
10 #include "chrome/browser/infobars/infobar_tab_helper.h" 10 #include "chrome/browser/infobars/infobar_tab_helper.h"
11 #include "chrome/browser/managed_mode/managed_mode.h" 11 #include "chrome/browser/managed_mode/managed_mode.h"
12 #include "chrome/browser/managed_mode/managed_user_service.h" 12 #include "chrome/browser/managed_mode/managed_user_service.h"
13 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 13 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
14 #include "chrome/browser/prefs/pref_service_syncable.h" 14 #include "chrome/browser/prefs/pref_service_syncable.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_navigator.h" 17 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/interstitial_page.h" 24 #include "content/public/browser/interstitial_page.h"
25 #include "content/public/browser/navigation_controller.h" 25 #include "content/public/browser/navigation_controller.h"
26 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
27 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void CheckShownPage(WebContents* tab, content::PageType page_type) { 87 void CheckShownPage(WebContents* tab, content::PageType page_type) {
88 ASSERT_FALSE(tab->IsCrashed()); 88 ASSERT_FALSE(tab->IsCrashed());
89 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 89 NavigationEntry* entry = tab->GetController().GetActiveEntry();
90 ASSERT_TRUE(entry); 90 ASSERT_TRUE(entry);
91 ASSERT_EQ(page_type, entry->GetPageType()); 91 ASSERT_EQ(page_type, entry->GetPageType());
92 } 92 }
93 93
94 // Checks if the current number of shown infobars is equal to |expected|. 94 // Checks if the current number of shown infobars is equal to |expected|.
95 void CheckNumberOfInfobars(unsigned int expected) { 95 void CheckNumberOfInfobars(unsigned int expected) {
96 EXPECT_EQ(expected, 96 EXPECT_EQ(expected,
97 InfoBarService::FromWebContents( 97 InfoBarService::FromWebContents(
98 chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); 98 browser()->tab_strip_model()->GetActiveWebContents())->
99 GetInfoBarCount());
99 } 100 }
100 101
101 // Acts on the interstitial and infobar according to the values set to 102 // Acts on the interstitial and infobar according to the values set to
102 // |interstitial_action| and |infobar_action|. 103 // |interstitial_action| and |infobar_action|.
103 void ActOnInterstitialAndInfobar(WebContents* tab, 104 void ActOnInterstitialAndInfobar(WebContents* tab,
104 InterstitialAction interstitial_action, 105 InterstitialAction interstitial_action,
105 InfobarAction infobar_action) { 106 InfobarAction infobar_action) {
106 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 107 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
107 ASSERT_TRUE(interstitial_page); 108 ASSERT_TRUE(interstitial_page);
108 109
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 ManagedUserService* managed_user_service_; 181 ManagedUserService* managed_user_service_;
181 }; 182 };
182 183
183 // Navigates to a URL which is not in a manual list, clicks preview on the 184 // Navigates to a URL which is not in a manual list, clicks preview on the
184 // interstitial and then allows the website. The website should now be in the 185 // interstitial and then allows the website. The website should now be in the
185 // manual whitelist. 186 // manual whitelist.
186 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, SimpleURLNotInAnyLists) { 187 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, SimpleURLNotInAnyLists) {
187 GURL test_url("http://www.example.com/files/simple.html"); 188 GURL test_url("http://www.example.com/files/simple.html");
188 ui_test_utils::NavigateToURL(browser(), test_url); 189 ui_test_utils::NavigateToURL(browser(), test_url);
189 190
190 WebContents* tab = chrome::GetActiveWebContents(browser()); 191 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
191 192
192 CheckShownPageIsInterstitial(tab); 193 CheckShownPageIsInterstitial(tab);
193 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT); 194 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT);
194 195
195 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 196 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
196 } 197 }
197 198
198 // Same as above just that the URL redirects to a second URL first. The initial 199 // Same as above just that the URL redirects to a second URL first. The initial
199 // exact URL should be in the whitelist as well as the second hostname. 200 // exact URL should be in the whitelist as well as the second hostname.
200 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, RedirectedURLsNotInAnyLists) { 201 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, RedirectedURLsNotInAnyLists) {
201 std::vector<std::string> url_list; 202 std::vector<std::string> url_list;
202 url_list.push_back("www.a.com"); 203 url_list.push_back("www.a.com");
203 std::string last_url("www.example.com/files/simple.html"); 204 std::string last_url("www.example.com/files/simple.html");
204 GURL test_url(GetRedirectURL(url_list, last_url)); 205 GURL test_url(GetRedirectURL(url_list, last_url));
205 206
206 ui_test_utils::NavigateToURL(browser(), test_url); 207 ui_test_utils::NavigateToURL(browser(), test_url);
207 208
208 WebContents* tab = chrome::GetActiveWebContents(browser()); 209 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
209 210
210 CheckShownPageIsInterstitial(tab); 211 CheckShownPageIsInterstitial(tab);
211 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT); 212 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT);
212 213
213 EXPECT_TRUE(managed_user_service_->IsInManualList( 214 EXPECT_TRUE(managed_user_service_->IsInManualList(
214 true, "http://.www.a.com/server-redirect")); 215 true, "http://.www.a.com/server-redirect"));
215 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 216 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
216 } 217 }
217 218
218 // Navigates to a URL in the whitelist. No interstitial should be shown and 219 // Navigates to a URL in the whitelist. No interstitial should be shown and
219 // the browser should navigate to the page. 220 // the browser should navigate to the page.
220 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, SimpleURLInWhitelist) { 221 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, SimpleURLInWhitelist) {
221 GURL test_url("http://www.example.com/files/simple.html"); 222 GURL test_url("http://www.example.com/files/simple.html");
222 ListValue whitelist; 223 ListValue whitelist;
223 whitelist.AppendString(test_url.host()); 224 whitelist.AppendString(test_url.host());
224 managed_user_service_->AddToManualList(true, whitelist); 225 managed_user_service_->AddToManualList(true, whitelist);
225 226
226 ui_test_utils::NavigateToURL(browser(), test_url); 227 ui_test_utils::NavigateToURL(browser(), test_url);
227 228
228 WebContents* tab = chrome::GetActiveWebContents(browser()); 229 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
229 230
230 CheckShownPageIsNotInterstitial(tab); 231 CheckShownPageIsNotInterstitial(tab);
231 232
232 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 233 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
233 } 234 }
234 235
235 // Navigates to a URL which redirects to another URL, both in the whitelist. 236 // Navigates to a URL which redirects to another URL, both in the whitelist.
236 // No interstitial should be shown and the browser should navigate to the page. 237 // No interstitial should be shown and the browser should navigate to the page.
237 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 238 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
238 RedirectedURLsBothInWhitelist) { 239 RedirectedURLsBothInWhitelist) {
239 std::vector<std::string> url_list; 240 std::vector<std::string> url_list;
240 url_list.push_back("www.a.com"); 241 url_list.push_back("www.a.com");
241 std::string last_url("www.example.com/files/simple.html"); 242 std::string last_url("www.example.com/files/simple.html");
242 GURL test_url(GetRedirectURL(url_list, last_url)); 243 GURL test_url(GetRedirectURL(url_list, last_url));
243 244
244 // Add both hostnames to the whitelist, should navigate without interstitial. 245 // Add both hostnames to the whitelist, should navigate without interstitial.
245 ListValue whitelist; 246 ListValue whitelist;
246 whitelist.AppendString("www.a.com"); 247 whitelist.AppendString("www.a.com");
247 whitelist.AppendString("www.example.com"); 248 whitelist.AppendString("www.example.com");
248 managed_user_service_->AddToManualList(true, whitelist); 249 managed_user_service_->AddToManualList(true, whitelist);
249 250
250 ui_test_utils::NavigateToURL(browser(), test_url); 251 ui_test_utils::NavigateToURL(browser(), test_url);
251 252
252 WebContents* tab = chrome::GetActiveWebContents(browser()); 253 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
253 254
254 CheckShownPageIsNotInterstitial(tab); 255 CheckShownPageIsNotInterstitial(tab);
255 256
256 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.a.com")); 257 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.a.com"));
257 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 258 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
258 } 259 }
259 260
260 // Only one URL is in the whitelist and the second not, so it should redirect, 261 // Only one URL is in the whitelist and the second not, so it should redirect,
261 // show an interstitial, then after clicking preview and clicking accept both 262 // show an interstitial, then after clicking preview and clicking accept both
262 // websites should be in the whitelist. 263 // websites should be in the whitelist.
263 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 264 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
264 RedirectedURLFirstInWhitelist) { 265 RedirectedURLFirstInWhitelist) {
265 std::vector<std::string> url_list; 266 std::vector<std::string> url_list;
266 url_list.push_back("www.a.com"); 267 url_list.push_back("www.a.com");
267 std::string last_url("www.example.com/files/simple.html"); 268 std::string last_url("www.example.com/files/simple.html");
268 GURL test_url(GetRedirectURL(url_list, last_url)); 269 GURL test_url(GetRedirectURL(url_list, last_url));
269 270
270 // Add the first URL to the whitelist. 271 // Add the first URL to the whitelist.
271 ListValue whitelist; 272 ListValue whitelist;
272 whitelist.AppendString("www.a.com"); 273 whitelist.AppendString("www.a.com");
273 managed_user_service_->AddToManualList(true, whitelist); 274 managed_user_service_->AddToManualList(true, whitelist);
274 275
275 ui_test_utils::NavigateToURL(browser(), test_url); 276 ui_test_utils::NavigateToURL(browser(), test_url);
276 277
277 WebContents* tab = chrome::GetActiveWebContents(browser()); 278 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
278 279
279 EXPECT_EQ(tab->GetURL().spec(), "http://" + last_url); 280 EXPECT_EQ(tab->GetURL().spec(), "http://" + last_url);
280 CheckShownPageIsInterstitial(tab); 281 CheckShownPageIsInterstitial(tab);
281 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT); 282 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT);
282 283
283 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.a.com")); 284 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.a.com"));
284 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 285 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
285 } 286 }
286 287
287 // This test navigates to a URL which is not in the whitelist but redirects to 288 // This test navigates to a URL which is not in the whitelist but redirects to
288 // one that is. The expected behavior is that the user will get an interstitial 289 // one that is. The expected behavior is that the user will get an interstitial
289 // and after clicking preview the user will see an infobar stating that the URL 290 // and after clicking preview the user will see an infobar stating that the URL
290 // was already in the whitelist (and the first URL gets added as well). 291 // was already in the whitelist (and the first URL gets added as well).
291 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 292 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
292 RedirectedURLLastInWhitelist) { 293 RedirectedURLLastInWhitelist) {
293 std::vector<std::string> url_list; 294 std::vector<std::string> url_list;
294 url_list.push_back("www.a.com"); 295 url_list.push_back("www.a.com");
295 std::string last_url("www.example.com/files/simple.html"); 296 std::string last_url("www.example.com/files/simple.html");
296 GURL test_url(GetRedirectURL(url_list, last_url)); 297 GURL test_url(GetRedirectURL(url_list, last_url));
297 298
298 // Add the last URL to the whitelist. 299 // Add the last URL to the whitelist.
299 ListValue whitelist; 300 ListValue whitelist;
300 whitelist.AppendString("www.example.com"); 301 whitelist.AppendString("www.example.com");
301 managed_user_service_->AddToManualList(true, whitelist); 302 managed_user_service_->AddToManualList(true, whitelist);
302 303
303 ui_test_utils::NavigateToURL(browser(), test_url); 304 ui_test_utils::NavigateToURL(browser(), test_url);
304 305
305 WebContents* tab = chrome::GetActiveWebContents(browser()); 306 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
306 307
307 EXPECT_EQ(tab->GetURL().host(), "www.a.com"); 308 EXPECT_EQ(tab->GetURL().host(), "www.a.com");
308 CheckShownPageIsInterstitial(tab); 309 CheckShownPageIsInterstitial(tab);
309 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, 310 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED,
310 INFOBAR_ALREADY_ADDED); 311 INFOBAR_ALREADY_ADDED);
311 312
312 EXPECT_TRUE(managed_user_service_->IsInManualList( 313 EXPECT_TRUE(managed_user_service_->IsInManualList(
313 true, "http://.www.a.com/server-redirect")); 314 true, "http://.www.a.com/server-redirect"));
314 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 315 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
315 } 316 }
316 317
317 // Tests whether going back after being shown an interstitial works. No 318 // Tests whether going back after being shown an interstitial works. No
318 // websites should be added to the whitelist. 319 // websites should be added to the whitelist.
319 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 320 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
320 SimpleURLNotInAnyListsGoBack) { 321 SimpleURLNotInAnyListsGoBack) {
321 GURL test_url("http://www.example.com/files/simple.html"); 322 GURL test_url("http://www.example.com/files/simple.html");
322 ui_test_utils::NavigateToURL(browser(), test_url); 323 ui_test_utils::NavigateToURL(browser(), test_url);
323 324
324 WebContents* tab = chrome::GetActiveWebContents(browser()); 325 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
325 326
326 CheckShownPageIsInterstitial(tab); 327 CheckShownPageIsInterstitial(tab);
327 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_DONTPROCEED, 328 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_DONTPROCEED,
328 INFOBAR_NOT_USED); 329 INFOBAR_NOT_USED);
329 330
330 EXPECT_EQ(tab->GetURL().spec(), "about:blank"); 331 EXPECT_EQ(tab->GetURL().spec(), "about:blank");
331 332
332 EXPECT_FALSE(managed_user_service_->IsInManualList(true, "www.example.com")); 333 EXPECT_FALSE(managed_user_service_->IsInManualList(true, "www.example.com"));
333 } 334 }
334 335
335 // Like SimpleURLNotInAnyLists just that it navigates to a page on the allowed 336 // Like SimpleURLNotInAnyLists just that it navigates to a page on the allowed
336 // domain after clicking allow on the infobar. The navigation should complete 337 // domain after clicking allow on the infobar. The navigation should complete
337 // and no interstitial should be shown the second time. 338 // and no interstitial should be shown the second time.
338 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 339 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
339 SimpleURLNotInAnyListsNavigateAgain) { 340 SimpleURLNotInAnyListsNavigateAgain) {
340 GURL test_url("http://www.example.com/files/simple.html"); 341 GURL test_url("http://www.example.com/files/simple.html");
341 ui_test_utils::NavigateToURL(browser(), test_url); 342 ui_test_utils::NavigateToURL(browser(), test_url);
342 343
343 WebContents* tab = chrome::GetActiveWebContents(browser()); 344 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
344 345
345 CheckShownPageIsInterstitial(tab); 346 CheckShownPageIsInterstitial(tab);
346 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT); 347 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT);
347 348
348 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 349 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
349 350
350 // Navigate to a different page on the same host. 351 // Navigate to a different page on the same host.
351 test_url = GURL("http://www.example.com/files/english_page.html"); 352 test_url = GURL("http://www.example.com/files/english_page.html");
352 ui_test_utils::NavigateToURL(browser(), test_url); 353 ui_test_utils::NavigateToURL(browser(), test_url);
353 354
354 // An interstitial should not show up. 355 // An interstitial should not show up.
355 CheckShownPageIsNotInterstitial(tab); 356 CheckShownPageIsNotInterstitial(tab);
356 CheckNumberOfInfobars(0); 357 CheckNumberOfInfobars(0);
357 } 358 }
358 359
359 // Same as above just that it reloads the page instead of navigating to another 360 // Same as above just that it reloads the page instead of navigating to another
360 // page on the website. Same expected behavior. 361 // page on the website. Same expected behavior.
361 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 362 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
362 SimpleURLNotInAnyListsReloadPageAfterAdd) { 363 SimpleURLNotInAnyListsReloadPageAfterAdd) {
363 GURL test_url("http://www.example.com/files/simple.html"); 364 GURL test_url("http://www.example.com/files/simple.html");
364 ui_test_utils::NavigateToURL(browser(), test_url); 365 ui_test_utils::NavigateToURL(browser(), test_url);
365 366
366 WebContents* tab = chrome::GetActiveWebContents(browser()); 367 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
367 368
368 CheckShownPageIsInterstitial(tab); 369 CheckShownPageIsInterstitial(tab);
369 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT); 370 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT);
370 371
371 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com")); 372 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "www.example.com"));
372 373
373 // Reload the page 374 // Reload the page
374 tab->GetController().Reload(false); 375 tab->GetController().Reload(false);
375 376
376 // Expect that the page shows up and not an interstitial. 377 // Expect that the page shows up and not an interstitial.
377 CheckShownPageIsNotInterstitial(tab); 378 CheckShownPageIsNotInterstitial(tab);
378 CheckNumberOfInfobars(0); 379 CheckNumberOfInfobars(0);
379 EXPECT_EQ(tab->GetURL().spec(), test_url.spec()); 380 EXPECT_EQ(tab->GetURL().spec(), test_url.spec());
380 } 381 }
381 382
382 // Navigates to an HTTPS page not in any lists, similar to the simple test but 383 // Navigates to an HTTPS page not in any lists, similar to the simple test but
383 // over HTTPS (expected behavior is that only the HTTPS version of the site 384 // over HTTPS (expected behavior is that only the HTTPS version of the site
384 // gets whitelisted, compared to the simple case where all protocols get 385 // gets whitelisted, compared to the simple case where all protocols get
385 // whitelisted). 386 // whitelisted).
386 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 387 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
387 SimpleHTTPSURLNotInAnyLists) { 388 SimpleHTTPSURLNotInAnyLists) {
388 // Navigate to an HTTPS URL. 389 // Navigate to an HTTPS URL.
389 GURL test_url("https://www.example.com/files/simple.html"); 390 GURL test_url("https://www.example.com/files/simple.html");
390 ui_test_utils::NavigateToURL(browser(), test_url); 391 ui_test_utils::NavigateToURL(browser(), test_url);
391 392
392 WebContents* tab = chrome::GetActiveWebContents(browser()); 393 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
393 394
394 CheckShownPageIsInterstitial(tab); 395 CheckShownPageIsInterstitial(tab);
395 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT); 396 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT);
396 397
397 // Check that the https:// version is added in the whitelist. 398 // Check that the https:// version is added in the whitelist.
398 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "https://www.example.c om")); 399 EXPECT_TRUE(managed_user_service_->IsInManualList(true, "https://www.example.c om"));
399 } 400 }
400 401
401 // The test navigates to a page, the interstitial is shown and preview is 402 // The test navigates to a page, the interstitial is shown and preview is
402 // clicked but then the test navigates to other pages on the same domain before 403 // clicked but then the test navigates to other pages on the same domain before
403 // clicking allow on the page. The "allow" infobar should still be there during 404 // clicking allow on the page. The "allow" infobar should still be there during
404 // this time and the navigation should be allowed. When the test finally clicks 405 // this time and the navigation should be allowed. When the test finally clicks
405 // accept the webpage should be whitelisted. 406 // accept the webpage should be whitelisted.
406 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 407 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
407 SimpleURLNotInAnyListNavigateAround) { 408 SimpleURLNotInAnyListNavigateAround) {
408 GURL test_url("http://www.example.com/files/simple.html"); 409 GURL test_url("http://www.example.com/files/simple.html");
409 ui_test_utils::NavigateToURL(browser(), test_url); 410 ui_test_utils::NavigateToURL(browser(), test_url);
410 411
411 WebContents* tab = chrome::GetActiveWebContents(browser()); 412 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
412 413
413 CheckShownPageIsInterstitial(tab); 414 CheckShownPageIsInterstitial(tab);
414 415
415 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 416 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
416 ASSERT_TRUE(interstitial_page); 417 ASSERT_TRUE(interstitial_page);
417 418
418 content::WindowedNotificationObserver infobar_added( 419 content::WindowedNotificationObserver infobar_added(
419 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 420 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
420 content::NotificationService::AllSources()); 421 content::NotificationService::AllSources());
421 422
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // The test navigates to a page, the interstitial is shown and preview is 467 // The test navigates to a page, the interstitial is shown and preview is
467 // clicked but then the test navigates to a page on a different host, which 468 // clicked but then the test navigates to a page on a different host, which
468 // should trigger an interstitial again. Clicking preview on this interstitial 469 // should trigger an interstitial again. Clicking preview on this interstitial
469 // and accepting it should add the second website to the whitelist and not the 470 // and accepting it should add the second website to the whitelist and not the
470 // first one. 471 // first one.
471 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 472 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
472 NavigateDifferentHostAfterPreview) { 473 NavigateDifferentHostAfterPreview) {
473 GURL test_url("http://www.example.com/files/simple.html"); 474 GURL test_url("http://www.example.com/files/simple.html");
474 ui_test_utils::NavigateToURL(browser(), test_url); 475 ui_test_utils::NavigateToURL(browser(), test_url);
475 476
476 WebContents* tab = chrome::GetActiveWebContents(browser()); 477 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
477 478
478 CheckShownPageIsInterstitial(tab); 479 CheckShownPageIsInterstitial(tab);
479 480
480 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 481 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
481 ASSERT_TRUE(interstitial_page); 482 ASSERT_TRUE(interstitial_page);
482 483
483 content::WindowedNotificationObserver infobar_added( 484 content::WindowedNotificationObserver infobar_added(
484 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 485 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
485 content::NotificationService::AllSources()); 486 content::NotificationService::AllSources());
486 487
(...skipping 15 matching lines...) Expand all
502 503
503 CheckShownPageIsInterstitial(tab); 504 CheckShownPageIsInterstitial(tab);
504 CheckNumberOfInfobars(0); 505 CheckNumberOfInfobars(0);
505 506
506 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT); 507 ActOnInterstitialAndInfobar(tab, INTERSTITIAL_PROCEED, INFOBAR_ACCEPT);
507 508
508 EXPECT_FALSE(managed_user_service_->IsInManualList(true, "www.example.com")); 509 EXPECT_FALSE(managed_user_service_->IsInManualList(true, "www.example.com"));
509 EXPECT_TRUE(managed_user_service_->IsInManualList(true, 510 EXPECT_TRUE(managed_user_service_->IsInManualList(true,
510 "www.new-example.com")); 511 "www.new-example.com"));
511 } 512 }
OLDNEW
« no previous file with comments | « chrome/browser/loadtimes_extension_bindings_browsertest.cc ('k') | chrome/browser/media/chrome_webrtc_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698