Chromium Code Reviews| Index: chrome/browser/plugins/flash_permission_browsertest.cc |
| diff --git a/chrome/browser/plugins/flash_permission_browsertest.cc b/chrome/browser/plugins/flash_permission_browsertest.cc |
| index 5a934dd64c6ab4a3f07d9e6365ab9f3f4a3c1ec0..91fb8641dc48f084293709aea377c3c9fc23352a 100644 |
| --- a/chrome/browser/plugins/flash_permission_browsertest.cc |
| +++ b/chrome/browser/plugins/flash_permission_browsertest.cc |
| @@ -17,6 +17,27 @@ |
| #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| #include "url/gurl.h" |
| +namespace { |
| + |
| +class PageReloadWaiter { |
|
nasko
2016/11/30 17:38:56
Why do we need this wrapper for TestNavigationMana
Alexander Semashko
2016/11/30 22:23:08
Yes, waiting only for commit here seems wrong.
Tes
nasko
2016/12/01 01:17:28
Maybe UrlLoadObserver then fits the picture better
Alexander Semashko
2016/12/01 12:24:59
Unfortunately, no. When an intermediate navigation
nasko
2016/12/01 17:23:09
: ( Is the intermediate navigation in the same fra
|
| + public: |
| + explicit PageReloadWaiter(content::WebContents* web_contents) |
| + : web_contents_(web_contents), |
| + navigation_observer_(web_contents, |
| + web_contents->GetLastCommittedURL()) {} |
| + |
| + void Wait() { |
| + navigation_observer_.WaitForNavigationFinished(); |
| + EXPECT_TRUE(content::WaitForLoadStop(web_contents_)); |
| + } |
| + |
| + private: |
| + content::WebContents* web_contents_; |
| + content::TestNavigationManager navigation_observer_; |
| +}; |
| + |
| +} // namespace |
| + |
| class FlashPermissionBrowserTest : public PermissionsBrowserTest { |
| public: |
| FlashPermissionBrowserTest() |
| @@ -44,20 +65,15 @@ class FlashPermissionBrowserTest : public PermissionsBrowserTest { |
| if (prompt_factory()->response_type() == |
| PermissionRequestManager::ACCEPT_ALL) { |
| // If the prompt will be allowed, we need to wait for the page to refresh. |
| - content::TestNavigationManager observer( |
| - GetWebContents(), GetWebContents()->GetLastCommittedURL()); |
| + PageReloadWaiter reload_waiter(GetWebContents()); |
| EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();")); |
| - observer.WaitForNavigationFinished(); |
| + reload_waiter.Wait(); |
| } else { |
| EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();")); |
| } |
| } |
| bool FeatureUsageSucceeds() override { |
| - // Wait until the page is refreshed before testing whether flash is enabled |
| - // or disabled. |
| - ui_test_utils::NavigateToURL(browser(), |
|
Alexander Semashko
2016/11/30 22:23:08
Just for the information.
This was an "extra" navi
|
| - GetWebContents()->GetLastCommittedURL()); |
| // If either flash with or without fallback content runs successfully it |
| // indicates the feature is at least partly working, which could imply a |
| // faulty permission. |
| @@ -86,7 +102,11 @@ IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) { |
| IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) { |
| EXPECT_EQ(0, prompt_factory()->total_request_count()); |
| prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + // FlashPermissionContext::UpdateTabContext will reload the page, we'll have |
| + // to wait until it is ready. |
| + PageReloadWaiter reload_waiter(GetWebContents()); |
| EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();")); |
| + reload_waiter.Wait(); |
| EXPECT_TRUE(FeatureUsageSucceeds()); |
| EXPECT_EQ(1, prompt_factory()->total_request_count()); |
| @@ -98,12 +118,12 @@ IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, |
| EXPECT_FALSE(FeatureUsageSucceeds()); |
| prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| // We need to simulate a mouse click to trigger the placeholder to prompt. |
| - content::TestNavigationManager observer( |
| - GetWebContents(), GetWebContents()->GetLastCommittedURL()); |
| + // When the prompt is auto-accepted, the page will be reloaded. |
| + PageReloadWaiter reload_waiter(GetWebContents()); |
| content::SimulateMouseClickAt(GetWebContents(), 0 /* modifiers */, |
| blink::WebMouseEvent::Button::Left, |
| gfx::Point(50, 50)); |
| - observer.WaitForNavigationFinished(); |
| + reload_waiter.Wait(); |
| EXPECT_TRUE(FeatureUsageSucceeds()); |
| EXPECT_EQ(1, prompt_factory()->total_request_count()); |