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

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

Issue 7736003: Revert 98539 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 98544)
+++ chrome/browser/prerender/prerender_browsertest.cc (working copy)
@@ -102,21 +102,19 @@
Profile* profile,
const GURL& url,
const GURL& referrer,
- int expected_number_of_loads,
+ int 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_(expected_number_of_loads),
+ expected_number_of_loads_(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() {
@@ -128,8 +126,9 @@
// 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
@@ -186,8 +185,6 @@
quit_message_loop_on_destruction_ = value;
}
- int number_of_loads() { return number_of_loads_; }
-
private:
virtual void OnRenderViewHostCreated(
RenderViewHost* new_render_view_host) OVERRIDE {
@@ -248,8 +245,11 @@
WaitForLoadPrerenderContentsFactory(
int number_of_loads,
const std::deque<FinalStatus>& expected_final_status_queue)
- : number_of_loads_(number_of_loads),
- expected_final_status_queue_(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());
VLOG(1) << "Factory created with queue length " <<
expected_final_status_queue_.size();
}
@@ -615,7 +615,7 @@
ASSERT_TRUE(prerender_contents != NULL);
EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status());
- if (call_javascript_ && total_navigations > 0) {
+ if (call_javascript_) {
// Check if page behaves as expected while in prerendered state.
bool prerender_test_result = false;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
@@ -625,7 +625,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);
}
@@ -641,18 +641,6 @@
if (disposition == NEW_BACKGROUND_TAB)
GetPrerenderContents()->set_should_be_shown(false);
- // In the case of zero loads, need to wait for the page load to complete
- // before running any Javascript.
- scoped_ptr<ui_test_utils::WindowedNotificationObserver> page_load_observer;
- TabContents* tab_contents =
- GetPrerenderContents()->prerender_contents()->tab_contents();
- if (GetPrerenderContents()->number_of_loads() == 0) {
- page_load_observer.reset(
- new ui_test_utils::WindowedNotificationObserver(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(&tab_contents->controller())));
- }
-
// ui_test_utils::NavigateToURL waits until DidStopLoading is called on
// the current tab. As that tab is going to end up deleted, and may never
// finish loading before that happens, exit the message loop on the deletion
@@ -669,9 +657,24 @@
EXPECT_TRUE(GetPrerenderContents() == NULL);
if (call_javascript_) {
- if (page_load_observer.get())
- page_load_observer->Wait();
+ // Check if page behaved as expected when actually displayed.
+ // Locate the navigated TabContents.
+ TabContents* tab_contents = NULL;
+ switch (disposition) {
+ case CURRENT_TAB:
+ case NEW_FOREGROUND_TAB:
+ tab_contents = browser()->GetSelectedTabContents();
+ break;
+ case NEW_BACKGROUND_TAB:
+ tab_contents =
+ browser()->GetTabContentsAt(browser()->active_index() + 1);
+ break;
+ default:
+ ASSERT_TRUE(false) << "Unsupported creation disposition";
+ }
+ ASSERT_TRUE(tab_contents);
+
bool display_test_result = false;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
tab_contents->render_view_host(), L"",
@@ -707,14 +710,6 @@
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) {
@@ -724,15 +719,6 @@
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) {
@@ -742,15 +728,6 @@
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