OLD | NEW |
---|---|
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 "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 10 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 browser(), | 293 browser(), |
294 embedded_test_server()->GetURL( | 294 embedded_test_server()->GetURL( |
295 "/permissions/requests-before-after-load.html"), | 295 "/permissions/requests-before-after-load.html"), |
296 1); | 296 1); |
297 bubble_factory()->WaitForPermissionBubble(); | 297 bubble_factory()->WaitForPermissionBubble(); |
298 | 298 |
299 EXPECT_EQ(1, bubble_factory()->show_count()); | 299 EXPECT_EQ(1, bubble_factory()->show_count()); |
300 EXPECT_EQ(1, bubble_factory()->total_request_count()); | 300 EXPECT_EQ(1, bubble_factory()->total_request_count()); |
301 } | 301 } |
302 | 302 |
303 // Tests that the permission bubble should only show on active browser | |
304 // (crbug.com/704350). | |
305 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, | |
306 ShowPromptOnActiveBrowser) { | |
307 ASSERT_TRUE(embedded_test_server()->Start()); | |
308 | |
309 // Simulate a native widget deactivation for browser(). | |
310 BrowserList::GetInstance()->NotifyBrowserNoLongerActive(browser()); | |
Qiang(Joe) Xu
2017/03/27 21:09:52
This is a work around for testing this, otherwise
| |
311 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | |
312 browser(), | |
313 embedded_test_server()->GetURL( | |
314 "/permissions/requests-before-after-load.html"), | |
315 1); | |
316 bubble_factory()->WaitForPermissionBubble(); | |
317 | |
318 EXPECT_EQ(0, bubble_factory()->show_count()); | |
319 EXPECT_EQ(0, bubble_factory()->total_request_count()); | |
320 | |
321 BrowserList::GetInstance()->SetLastActive(browser()); | |
322 bubble_factory()->WaitForPermissionBubble(); | |
323 EXPECT_EQ(1, bubble_factory()->show_count()); | |
324 EXPECT_EQ(1, bubble_factory()->total_request_count()); | |
325 } | |
326 | |
303 // 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 |
304 // showing the bubbles twice. | 328 // showing the bubbles twice. |
305 // http://crbug.com/512849 flaky | 329 // http://crbug.com/512849 flaky |
306 #if defined(OS_WIN) | 330 #if defined(OS_WIN) |
307 #define MAYBE_NavTwice DISABLED_NavTwice | 331 #define MAYBE_NavTwice DISABLED_NavTwice |
308 #else | 332 #else |
309 #define MAYBE_NavTwice NavTwice | 333 #define MAYBE_NavTwice NavTwice |
310 #endif | 334 #endif |
311 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, MAYBE_NavTwice) { | 335 IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, MAYBE_NavTwice) { |
312 ASSERT_TRUE(embedded_test_server()->Start()); | 336 ASSERT_TRUE(embedded_test_server()->Start()); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 #define MAYBE_InvokeDialog_protected_media InvokeDialog_protected_media | 515 #define MAYBE_InvokeDialog_protected_media InvokeDialog_protected_media |
492 #else | 516 #else |
493 #define MAYBE_InvokeDialog_protected_media DISABLED_InvokeDialog_protected_media | 517 #define MAYBE_InvokeDialog_protected_media DISABLED_InvokeDialog_protected_media |
494 #endif | 518 #endif |
495 IN_PROC_BROWSER_TEST_F(PermissionDialogTest, | 519 IN_PROC_BROWSER_TEST_F(PermissionDialogTest, |
496 MAYBE_InvokeDialog_protected_media) { | 520 MAYBE_InvokeDialog_protected_media) { |
497 RunDialog(); | 521 RunDialog(); |
498 } | 522 } |
499 | 523 |
500 } // anonymous namespace | 524 } // anonymous namespace |
OLD | NEW |