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

Unified Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 1896943002: Remove PrerenderManager::OnCloseWebContentsDeleter::SwappedOut (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make it compile Created 4 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
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_browsertest.cc
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 630f23916789f0a45ff437659a82c3cb15db3ad9..9eec60fa294f02a3d36490018784ad8e1cc5b9c2 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -326,6 +326,27 @@ class ChannelDestructionWatcher {
DISALLOW_COPY_AND_ASSIGN(ChannelDestructionWatcher);
};
+// A navigation observer to wait until WebContents is destroyed.
+class WebContentsDestructionObserver : public WebContentsObserver {
+ public:
+ explicit WebContentsDestructionObserver(WebContents* web_contents)
+ : WebContentsObserver(web_contents) {}
+
+ // Waits for destruction of the observed WebContents.
+ void Wait() {
+ loop_.Run();
+ }
+
+ // WebContentsObserver implementation:
+ void WebContentsDestroyed() override {
+ loop_.Quit();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebContentsDestructionObserver);
+ base::RunLoop loop_;
+};
+
// A navigation observer to wait on either a new load or a swap of a
// WebContents. On swap, if the new WebContents is still loading, wait for that
// load to complete as well. Note that the load must begin after the observer is
@@ -3074,7 +3095,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) {
}
// Checks that when a prerendered page is swapped in to a referring page, the
-// unload handlers on the referring page are executed.
+// unload handlers on the referring page are executed and its WebContents is
+// destroyed.
+// TODO(pasko): A similar test for BeforeUnload. See http://crbug.com/600693
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) {
// Matches URL in prerender_loader_with_unload.html.
const GURL unload_url("http://unload-url.test");
@@ -3088,8 +3111,10 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) {
set_loader_path("/prerender/prerender_loader_with_unload.html");
PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
+ WebContentsDestructionObserver destruction_observer(GetActiveWebContents());
NavigateToDestURL();
unload_counter.WaitForCount(1);
+ destruction_observer.Wait();
}
// Checks that a hanging unload on the referring page of a prerender swap does
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698