Commit 0762c388 authored by Alexander Semashko's avatar Alexander Semashko Committed by Commit Bot

Fix/deflake tests in /chrome/browser/unload_browsertest.cc.

This is a prerequisite for switching WindowedNotificationObserver to use
base::RunLoop instead of deprecated MessageLoopRunner.

This CL is split out from https://crrev.com/c/982612.

This CL was uploaded by git cl split.

R=alexmos@chromium.org

Bug: 668707
Change-Id: I2d723e7938ac7e07c6334e58b26b60e7e493834e
Reviewed-on: https://chromium-review.googlesource.com/1120487Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Commit-Queue: Alexander Semashko <ahest@yandex-team.ru>
Cr-Commit-Position: refs/heads/master@{#571661}
parent f4924c30
......@@ -149,10 +149,15 @@ class UnloadTestBase : public InProcessBrowserTest {
base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
}
void CheckTitle(const char* expected_title) {
void CheckTitle(const char* expected_title, bool wait = false) {
auto* web_contents = browser()->tab_strip_model()->GetActiveWebContents();
base::string16 expected = base::ASCIIToUTF16(expected_title);
EXPECT_EQ(expected,
browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
base::string16 actual;
if (wait)
actual = content::TitleWatcher(web_contents, expected).WaitAndGetTitle();
else
actual = web_contents->GetTitle();
EXPECT_EQ(expected, actual);
}
void NavigateToDataURL(const char* html_content, const char* expected_title) {
......@@ -633,15 +638,13 @@ IN_PROC_BROWSER_TEST_P(UnloadTest, BrowserCloseTabWhenOtherTabHasListener) {
content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
content::WindowedNotificationObserver load_stop_observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
content::SimulateMouseClick(
browser()->tab_strip_model()->GetActiveWebContents(), 0,
blink::WebMouseEvent::Button::kLeft);
observer.Wait();
load_stop_observer.Wait();
CheckTitle("popup");
// Need to wait for the title, because the initial page (about:blank) can stop
// loading before the click handler calls document.write.
CheckTitle("popup", true);
content::WebContentsDestroyedWatcher destroyed_watcher(
browser()->tab_strip_model()->GetActiveWebContents());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment