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

Unified Diff: chrome/browser/plugins/flash_permission_browsertest.cc

Issue 2540683002: Don't defer quitting in ExecuteScript and other helpers that use DOMMessageQueue. (Closed)
Patch Set: Address comments. Created 4 years 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 side-by-side diff with in-line comments
Download patch
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..bfcfec0a6ee0fb66e56026254e84c4342239f419 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 {
+ public:
+ explicit PageReloadWaiter(content::WebContents* web_contents)
+ : web_contents_(web_contents),
+ navigation_observer_(web_contents,
+ web_contents->GetLastCommittedURL()) {}
+
+ bool Wait() {
+ navigation_observer_.WaitForNavigationFinished();
+ return 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();
+ EXPECT_TRUE(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(),
- 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();"));
+ EXPECT_TRUE(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();
+ EXPECT_TRUE(reload_waiter.Wait());
EXPECT_TRUE(FeatureUsageSucceeds());
EXPECT_EQ(1, prompt_factory()->total_request_count());

Powered by Google App Engine
This is Rietveld 408576698