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

Side by Side Diff: chrome/browser/permissions/permission_request_manager_browsertest.cc

Issue 2835863003: MediaStreamDevicesControllerBrowserTest (Closed)
Patch Set: MediaStreamDevicesControllerBrowserTest Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/permissions/permission_request_manager.h" 5 #include "chrome/browser/permissions/permission_request_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/test/scoped_feature_list.h" 9 #include "base/test/scoped_feature_list.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 DISABLED_RequestsBeforeLoad) { 298 DISABLED_RequestsBeforeLoad) {
299 ASSERT_TRUE(embedded_test_server()->Start()); 299 ASSERT_TRUE(embedded_test_server()->Start());
300 300
301 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 301 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
302 browser(), 302 browser(),
303 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 303 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
304 1); 304 1);
305 bubble_factory()->WaitForPermissionBubble(); 305 bubble_factory()->WaitForPermissionBubble();
306 306
307 EXPECT_EQ(1, bubble_factory()->show_count()); 307 EXPECT_EQ(1, bubble_factory()->show_count());
308 EXPECT_EQ(2, bubble_factory()->total_request_count()); 308 EXPECT_EQ(2, bubble_factory()->TotalRequestCount());
309 } 309 }
310 310
311 // Requests before the load should not be bundled with a request after the load. 311 // Requests before the load should not be bundled with a request after the load.
312 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, 312 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
313 RequestsBeforeAfterLoad) { 313 RequestsBeforeAfterLoad) {
314 ASSERT_TRUE(embedded_test_server()->Start()); 314 ASSERT_TRUE(embedded_test_server()->Start());
315 315
316 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 316 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
317 browser(), 317 browser(),
318 embedded_test_server()->GetURL( 318 embedded_test_server()->GetURL(
319 "/permissions/requests-before-after-load.html"), 319 "/permissions/requests-before-after-load.html"),
320 1); 320 1);
321 bubble_factory()->WaitForPermissionBubble(); 321 bubble_factory()->WaitForPermissionBubble();
322 322
323 EXPECT_EQ(1, bubble_factory()->show_count()); 323 EXPECT_EQ(1, bubble_factory()->show_count());
324 EXPECT_EQ(1, bubble_factory()->total_request_count()); 324 EXPECT_EQ(1, bubble_factory()->TotalRequestCount());
325 } 325 }
326 326
327 // Navigating twice to the same URL should be equivalent to refresh. This means 327 // Navigating twice to the same URL should be equivalent to refresh. This means
328 // showing the bubbles twice. 328 // showing the bubbles twice.
329 // http://crbug.com/512849 flaky 329 // http://crbug.com/512849 flaky
330 #if defined(OS_WIN) 330 #if defined(OS_WIN)
331 #define MAYBE_NavTwice DISABLED_NavTwice 331 #define MAYBE_NavTwice DISABLED_NavTwice
332 #else 332 #else
333 #define MAYBE_NavTwice NavTwice 333 #define MAYBE_NavTwice NavTwice
334 #endif 334 #endif
335 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, MAYBE_NavTwice) { 335 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, MAYBE_NavTwice) {
336 ASSERT_TRUE(embedded_test_server()->Start()); 336 ASSERT_TRUE(embedded_test_server()->Start());
337 337
338 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 338 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
339 browser(), 339 browser(),
340 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 340 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
341 1); 341 1);
342 bubble_factory()->WaitForPermissionBubble(); 342 bubble_factory()->WaitForPermissionBubble();
343 343
344 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 344 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
345 browser(), 345 browser(),
346 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 346 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
347 1); 347 1);
348 bubble_factory()->WaitForPermissionBubble(); 348 bubble_factory()->WaitForPermissionBubble();
349 349
350 EXPECT_EQ(2, bubble_factory()->show_count()); 350 EXPECT_EQ(2, bubble_factory()->show_count());
351 EXPECT_EQ(4, bubble_factory()->total_request_count()); 351 EXPECT_EQ(4, bubble_factory()->TotalRequestCount());
352 } 352 }
353 353
354 // Navigating twice to the same URL with a hash should be navigation within the 354 // Navigating twice to the same URL with a hash should be navigation within the
355 // page. This means the bubble is only shown once. 355 // page. This means the bubble is only shown once.
356 // http://crbug.com/512849 flaky 356 // http://crbug.com/512849 flaky
357 #if defined(OS_WIN) 357 #if defined(OS_WIN)
358 #define MAYBE_NavTwiceWithHash DISABLED_NavTwiceWithHash 358 #define MAYBE_NavTwiceWithHash DISABLED_NavTwiceWithHash
359 #else 359 #else
360 #define MAYBE_NavTwiceWithHash NavTwiceWithHash 360 #define MAYBE_NavTwiceWithHash NavTwiceWithHash
361 #endif 361 #endif
362 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, 362 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
363 MAYBE_NavTwiceWithHash) { 363 MAYBE_NavTwiceWithHash) {
364 ASSERT_TRUE(embedded_test_server()->Start()); 364 ASSERT_TRUE(embedded_test_server()->Start());
365 365
366 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 366 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
367 browser(), 367 browser(),
368 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 368 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
369 1); 369 1);
370 bubble_factory()->WaitForPermissionBubble(); 370 bubble_factory()->WaitForPermissionBubble();
371 371
372 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 372 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
373 browser(), 373 browser(),
374 embedded_test_server()->GetURL( 374 embedded_test_server()->GetURL(
375 "/permissions/requests-before-load.html#0"), 375 "/permissions/requests-before-load.html#0"),
376 1); 376 1);
377 bubble_factory()->WaitForPermissionBubble(); 377 bubble_factory()->WaitForPermissionBubble();
378 378
379 EXPECT_EQ(1, bubble_factory()->show_count()); 379 EXPECT_EQ(1, bubble_factory()->show_count());
380 EXPECT_EQ(2, bubble_factory()->total_request_count()); 380 EXPECT_EQ(2, bubble_factory()->TotalRequestCount());
381 } 381 }
382 382
383 // Bubble requests should be shown after in-page navigation. 383 // Bubble requests should be shown after in-page navigation.
384 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, InPageNavigation) { 384 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, InPageNavigation) {
385 ASSERT_TRUE(embedded_test_server()->Start()); 385 ASSERT_TRUE(embedded_test_server()->Start());
386 386
387 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 387 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
388 browser(), 388 browser(),
389 embedded_test_server()->GetURL("/empty.html"), 389 embedded_test_server()->GetURL("/empty.html"),
390 1); 390 1);
391 391
392 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 392 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
393 browser(), 393 browser(),
394 embedded_test_server()->GetURL("/empty.html#0"), 394 embedded_test_server()->GetURL("/empty.html#0"),
395 1); 395 1);
396 396
397 // Request 'geolocation' permission. 397 // Request 'geolocation' permission.
398 ExecuteScriptAndGetValue( 398 ExecuteScriptAndGetValue(
399 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(), 399 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(),
400 "navigator.geolocation.getCurrentPosition(function(){});"); 400 "navigator.geolocation.getCurrentPosition(function(){});");
401 bubble_factory()->WaitForPermissionBubble(); 401 bubble_factory()->WaitForPermissionBubble();
402 402
403 EXPECT_EQ(1, bubble_factory()->show_count()); 403 EXPECT_EQ(1, bubble_factory()->show_count());
404 EXPECT_EQ(1, bubble_factory()->total_request_count()); 404 EXPECT_EQ(1, bubble_factory()->TotalRequestCount());
405 } 405 }
406 406
407 // Bubble requests should not be shown when the killswitch is on. 407 // Bubble requests should not be shown when the killswitch is on.
408 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, 408 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
409 KillSwitchGeolocation) { 409 KillSwitchGeolocation) {
410 ASSERT_TRUE(embedded_test_server()->Start()); 410 ASSERT_TRUE(embedded_test_server()->Start());
411 411
412 ui_test_utils::NavigateToURL( 412 ui_test_utils::NavigateToURL(
413 browser(), 413 browser(),
414 embedded_test_server()->GetURL("/permissions/killswitch_tester.html")); 414 embedded_test_server()->GetURL("/permissions/killswitch_tester.html"));
415 415
416 // Now enable the geolocation killswitch. 416 // Now enable the geolocation killswitch.
417 EnableKillSwitch(CONTENT_SETTINGS_TYPE_GEOLOCATION); 417 EnableKillSwitch(CONTENT_SETTINGS_TYPE_GEOLOCATION);
418 content::WebContents* web_contents = 418 content::WebContents* web_contents =
419 browser()->tab_strip_model()->GetActiveWebContents(); 419 browser()->tab_strip_model()->GetActiveWebContents();
420 420
421 std::string result; 421 std::string result;
422 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 422 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
423 web_contents, "requestGeolocation();", &result)); 423 web_contents, "requestGeolocation();", &result));
424 EXPECT_EQ("denied", result); 424 EXPECT_EQ("denied", result);
425 EXPECT_EQ(0, bubble_factory()->show_count()); 425 EXPECT_EQ(0, bubble_factory()->show_count());
426 EXPECT_EQ(0, bubble_factory()->total_request_count()); 426 EXPECT_EQ(0, bubble_factory()->TotalRequestCount());
427 427
428 // Disable the trial. 428 // Disable the trial.
429 variations::testing::ClearAllVariationParams(); 429 variations::testing::ClearAllVariationParams();
430 430
431 // Reload the page to get around blink layer caching for geolocation 431 // Reload the page to get around blink layer caching for geolocation
432 // requests. 432 // requests.
433 ui_test_utils::NavigateToURL( 433 ui_test_utils::NavigateToURL(
434 browser(), 434 browser(),
435 embedded_test_server()->GetURL("/permissions/killswitch_tester.html")); 435 embedded_test_server()->GetURL("/permissions/killswitch_tester.html"));
436 436
437 EXPECT_TRUE(content::ExecuteScript(web_contents, "requestGeolocation();")); 437 EXPECT_TRUE(content::ExecuteScript(web_contents, "requestGeolocation();"));
438 bubble_factory()->WaitForPermissionBubble(); 438 bubble_factory()->WaitForPermissionBubble();
439 EXPECT_EQ(1, bubble_factory()->show_count()); 439 EXPECT_EQ(1, bubble_factory()->show_count());
440 EXPECT_EQ(1, bubble_factory()->total_request_count()); 440 EXPECT_EQ(1, bubble_factory()->TotalRequestCount());
441 } 441 }
442 442
443 // Bubble requests should not be shown when the killswitch is on. 443 // Bubble requests should not be shown when the killswitch is on.
444 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, 444 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
445 KillSwitchNotifications) { 445 KillSwitchNotifications) {
446 ASSERT_TRUE(embedded_test_server()->Start()); 446 ASSERT_TRUE(embedded_test_server()->Start());
447 447
448 ui_test_utils::NavigateToURL( 448 ui_test_utils::NavigateToURL(
449 browser(), 449 browser(),
450 embedded_test_server()->GetURL("/permissions/killswitch_tester.html")); 450 embedded_test_server()->GetURL("/permissions/killswitch_tester.html"));
451 451
452 // Now enable the notifications killswitch. 452 // Now enable the notifications killswitch.
453 EnableKillSwitch(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 453 EnableKillSwitch(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
454 content::WebContents* web_contents = 454 content::WebContents* web_contents =
455 browser()->tab_strip_model()->GetActiveWebContents(); 455 browser()->tab_strip_model()->GetActiveWebContents();
456 456
457 std::string result; 457 std::string result;
458 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 458 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
459 web_contents, "requestNotification();", &result)); 459 web_contents, "requestNotification();", &result));
460 EXPECT_EQ("denied", result); 460 EXPECT_EQ("denied", result);
461 EXPECT_EQ(0, bubble_factory()->show_count()); 461 EXPECT_EQ(0, bubble_factory()->show_count());
462 EXPECT_EQ(0, bubble_factory()->total_request_count()); 462 EXPECT_EQ(0, bubble_factory()->TotalRequestCount());
463 463
464 // Disable the trial. 464 // Disable the trial.
465 variations::testing::ClearAllVariationParams(); 465 variations::testing::ClearAllVariationParams();
466 466
467 EXPECT_TRUE(content::ExecuteScript(web_contents, "requestNotification();")); 467 EXPECT_TRUE(content::ExecuteScript(web_contents, "requestNotification();"));
468 bubble_factory()->WaitForPermissionBubble(); 468 bubble_factory()->WaitForPermissionBubble();
469 EXPECT_EQ(1, bubble_factory()->show_count()); 469 EXPECT_EQ(1, bubble_factory()->show_count());
470 EXPECT_EQ(1, bubble_factory()->total_request_count()); 470 EXPECT_EQ(1, bubble_factory()->TotalRequestCount());
471 } 471 }
472 472
473 // Host wants to run flash. 473 // Host wants to run flash.
474 IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_flash) { 474 IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_flash) {
475 RunDialog(); 475 RunDialog();
476 } 476 }
477 477
478 // Host wants to know your location. 478 // Host wants to know your location.
479 IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_geolocation) { 479 IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_geolocation) {
480 RunDialog(); 480 RunDialog();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 #define MAYBE_InvokeDialog_protected_media InvokeDialog_protected_media 536 #define MAYBE_InvokeDialog_protected_media InvokeDialog_protected_media
537 #else 537 #else
538 #define MAYBE_InvokeDialog_protected_media DISABLED_InvokeDialog_protected_media 538 #define MAYBE_InvokeDialog_protected_media DISABLED_InvokeDialog_protected_media
539 #endif 539 #endif
540 IN_PROC_BROWSER_TEST_F(PermissionDialogTest, 540 IN_PROC_BROWSER_TEST_F(PermissionDialogTest,
541 MAYBE_InvokeDialog_protected_media) { 541 MAYBE_InvokeDialog_protected_media) {
542 RunDialog(); 542 RunDialog();
543 } 543 }
544 544
545 } // anonymous namespace 545 } // anonymous namespace
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_request_manager.cc ('k') | chrome/browser/permissions/permissions_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698