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

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

Issue 7693029: Deflake PrerenderExcessiveMemory, fix race (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to dominich's comments Created 9 years, 4 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_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_browsertest.cc
===================================================================
--- chrome/browser/prerender/prerender_browsertest.cc (revision 98269)
+++ chrome/browser/prerender/prerender_browsertest.cc (working copy)
@@ -102,19 +102,21 @@
Profile* profile,
const GURL& url,
const GURL& referrer,
- int number_of_loads,
+ int expected_number_of_loads,
FinalStatus expected_final_status)
: PrerenderContents(prerender_manager, prerender_tracker, profile,
url, referrer, ORIGIN_LINK_REL_PRERENDER,
PrerenderManager::kNoExperiment),
number_of_loads_(0),
- expected_number_of_loads_(number_of_loads),
+ expected_number_of_loads_(expected_number_of_loads),
expected_final_status_(expected_final_status),
new_render_view_host_(NULL),
was_hidden_(false),
was_shown_(false),
should_be_shown_(expected_final_status == FINAL_STATUS_USED),
quit_message_loop_on_destruction_(true) {
+ if (expected_number_of_loads == 0)
+ MessageLoopForUI::current()->Quit();
}
virtual ~TestPrerenderContents() {
@@ -126,9 +128,8 @@
// navigation, so this should be happen for every PrerenderContents for
// which a RenderViewHost is created, regardless of whether or not it's
// used.
- if (new_render_view_host_) {
+ if (new_render_view_host_)
EXPECT_TRUE(was_hidden_);
- }
// A used PrerenderContents will only be destroyed when we swap out
// TabContents, at the end of a navigation caused by a call to
@@ -245,11 +246,8 @@
WaitForLoadPrerenderContentsFactory(
int number_of_loads,
const std::deque<FinalStatus>& expected_final_status_queue)
- : number_of_loads_(number_of_loads) {
- expected_final_status_queue_.resize(expected_final_status_queue.size());
- std::copy(expected_final_status_queue.begin(),
- expected_final_status_queue.end(),
- expected_final_status_queue_.begin());
+ : number_of_loads_(number_of_loads),
+ expected_final_status_queue_(expected_final_status_queue) {
VLOG(1) << "Factory created with queue length " <<
expected_final_status_queue_.size();
}
@@ -615,7 +613,7 @@
ASSERT_TRUE(prerender_contents != NULL);
EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status());
- if (call_javascript_) {
+ if (call_javascript_ && total_navigations > 0) {
// Check if page behaves as expected while in prerendered state.
bool prerender_test_result = false;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
@@ -625,7 +623,7 @@
EXPECT_TRUE(prerender_test_result);
}
} else {
- // In the failure case, we should have removed dest_url_ from the
+ // In the failure case, we should have removed |dest_url_| from the
// prerender_manager.
EXPECT_TRUE(prerender_contents == NULL);
}
@@ -674,6 +672,8 @@
ASSERT_TRUE(false) << "Unsupported creation disposition";
}
ASSERT_TRUE(tab_contents);
+ if (tab_contents->IsLoading())
Paweł Hajdan Jr. 2011/08/25 23:32:52 I think this may be prone to flakiness. Have you c
mmenke 2011/08/26 15:47:20 I don't think there was any flakiness in this part
+ ui_test_utils::WaitForLoadStop(tab_contents);
bool display_test_result = false;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
@@ -710,6 +710,14 @@
NavigateToDestURL();
}
+// Checks that the visibility API works when the prerender is quickly opened
+// in a new tab before it stops loading.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderVisibilityQuickSwitch) {
+ PrerenderTestURL("files/prerender/prerender_visibility_quick.html",
+ FINAL_STATUS_USED, 0);
+ NavigateToDestURL();
+}
+
// Checks that the visibility API works when opening a page in a new hidden
// tab.
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderVisibilityBackgroundTab) {
@@ -719,6 +727,15 @@
NavigateToDestURLWithDisposition(NEW_BACKGROUND_TAB);
}
+// Checks that the visibility API works when opening a page in a new hidden
+// tab, which is switched to before it stops loading.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
+ PrerenderVisibilityBackgroundTabQuickSwitch) {
+ PrerenderTestURL("files/prerender/prerender_visibility_hidden_quick.html",
+ FINAL_STATUS_USED, 0);
+ NavigateToDestURLWithDisposition(NEW_BACKGROUND_TAB);
+}
+
// Checks that the visibility API works when opening a page in a new foreground
// tab.
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderVisibilityForegroundTab) {
@@ -728,6 +745,15 @@
NavigateToDestURLWithDisposition(NEW_FOREGROUND_TAB);
}
+// Checks that the visibility API works when the prerender is quickly opened
+// in a new tab foreground before it stops loading.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
+ PrerenderVisibilityForegroundTabQuickSwitch) {
+ PrerenderTestURL("files/prerender/prerender_visibility_quick.html",
+ FINAL_STATUS_USED, 0);
+ NavigateToDestURL();
+}
+
// Checks that the prerendering of a page is canceled correctly when a
// Javascript alert is called.
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAlertBeforeOnload) {
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698