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

Unified Diff: chrome/browser/unload_browsertest.cc

Issue 26277010: Create content::WebContentsDestroyedWatcher, use it in many tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 2 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 2d4917e5d4ff356720cfffe0f8a921f5bb20f2b1..433d20601f02639030e0ac85d85071e83ec220b6 100644
--- a/chrome/browser/unload_browsertest.cc
+++ b/chrome/browser/unload_browsertest.cc
@@ -406,11 +406,10 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseTabWhenOtherTabHasListener) {
load_stop_observer.Wait();
CheckTitle("popup");
- content::WindowedNotificationObserver tab_close_observer(
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::NotificationService::AllSources());
+ content::WebContentsDestroyedWatcher destroyed_watcher(
+ browser()->tab_strip_model()->GetActiveWebContents());
chrome::CloseTab(browser());
- tab_close_observer.Wait();
+ destroyed_watcher.Wait();
CheckTitle("only_one_unload");
}
@@ -494,6 +493,9 @@ IN_PROC_BROWSER_TEST_F(FastUnloadTest, MAYBE_UnloadHidden) {
NavigateToPageInNewTab("unload_sets_cookie");
EXPECT_EQ("", GetCookies("no_listeners"));
+ content::WebContentsDestroyedWatcher destroyed_watcher(
+ browser()->tab_strip_model()->GetActiveWebContents());
+
{
base::RunLoop run_loop;
FastTabCloseTabStripModelObserver observer(
@@ -506,16 +508,10 @@ IN_PROC_BROWSER_TEST_F(FastUnloadTest, MAYBE_UnloadHidden) {
CheckTitle("no_listeners");
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- // Show that the web contents to go away after the was removed.
- // Without unload-detached, this times-out because it happens earlier.
- content::WindowedNotificationObserver contents_destroyed_observer(
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::NotificationService::AllSources());
- contents_destroyed_observer.Wait();
+ // Wait for the actual destruction.
+ destroyed_watcher.Wait();
- // Browser still has the same tab.
- CheckTitle("no_listeners");
- EXPECT_EQ(1, browser()->tab_strip_model()->count());
+ // Verify that the destruction had the desired effect.
EXPECT_EQ("unloaded=ohyeah", GetCookies("no_listeners"));
}

Powered by Google App Engine
This is Rietveld 408576698