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

Unified Diff: chrome/browser/unload_browsertest.cc

Issue 2740783003: Revert "Revert of Reland: Switch WindowedNotificationObserver to use base::RunLoop. (patchset #3 id… (Closed)
Patch Set: Fix comment. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/unload_browsertest.cc
diff --git a/chrome/browser/unload_browsertest.cc b/chrome/browser/unload_browsertest.cc
index ae66d8c3002daa0b7a8d0c0df32da291f1b1a834..9948a187481ff6ec308bd7f3c5808665780ba31a 100644
--- a/chrome/browser/unload_browsertest.cc
+++ b/chrome/browser/unload_browsertest.cc
@@ -151,10 +151,15 @@ class UnloadTest : 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) {
@@ -612,15 +617,13 @@ IN_PROC_BROWSER_TEST_F(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());
« no previous file with comments | « chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc ('k') | content/public/test/test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698