summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prerender/prerender_browsertest.cc
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-27 04:35:13 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-27 04:35:13 +0000
commit208ce7e5e178bca7c7845b5c5129505ee85064ae (patch)
tree5ed7ff8cff680377430d0b26d951de46732fbff5 /chrome/browser/prerender/prerender_browsertest.cc
parent9639b940f0c7701c63ef21036f979ae6a76ccc17 (diff)
downloadchromium_src-208ce7e5e178bca7c7845b5c5129505ee85064ae.zip
chromium_src-208ce7e5e178bca7c7845b5c5129505ee85064ae.tar.gz
chromium_src-208ce7e5e178bca7c7845b5c5129505ee85064ae.tar.bz2
Revert 98539
Test fails consistently on Linux Views bots: PrerenderBrowserTest.PrerenderVisibilityBackgroundTab: [6686:6686:0826/200949:368667468:WARNING:zygote_host_linux.cc(148)] Running without the SUID sandbox! See http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on. [6686:6686:0826/200949:368753313:WARNING:proxy_config_service_impl.cc(654)] Error retrieving proxy setting from device [6686:6686:0826/200949:368754972:WARNING:wm_ipc.cc(311)] Missing _CHROME_LAYOUT_MODE property on root window [6686:6691:0826/200949:368757012:INFO:gl_implementation.cc(94)] Using desktop GL implementation. [6686:6691:0826/200949:368762612:ERROR:gl_surface_glx.cc(64)] GLX 1.3 or later is required. [6686:6691:0826/200949:368762779:ERROR:gl_surface_linux.cc(73)] GLSurfaceGLX::InitializeOneOff failed. [6686:6691:0826/200949:368762962:ERROR:gpu_info_collector_linux.cc(216)] gfx::GLContext::InitializeOneOff() failed [6686:6686:0826/200949:368808876:ERROR:timezone_settings.cc(61)] GetTimezoneID: Cannot read timezone symlink /var/lib/timezone/localtime [6686:6686:0826/200949:368808913:ERROR:timezone_settings.cc(141)] Got an empty string for timezone, default to America/Los_Angeles [6686:6686:0826/200949:368816216:WARNING:input_method_manager.cc(146)] No active input methods found. [6686:6686:0826/200949:368818013:WARNING:input_method_manager.cc(146)] No active input methods found. [6686:6686:0826/200949:368818259:WARNING:input_method_manager.cc(146)] No active input methods found. [6686:6686:0826/200950:369084812:WARNING:native_widget_gtk.cc(418)] compositing not supported; allowing anyway chrome/browser/prerender/prerender_browsertest.cc:680: Failure Value of: display_test_result Actual: false Expected: true - Deflake PrerenderExcessiveMemory, fixing a race in setting the visibility state of prerendered RenderViews in the process. Also add some more visibility API tests that would have reliably failed when losing the fixed race. BUG=93081 TEST=PrerenderBrowserTest.PrerenderExcessiveMemory. PrerenderBrowserTest.PrerenderInfiniteLoop Review URL: http://codereview.chromium.org/7693029 TBR=mmenke@chromium.org Review URL: http://codereview.chromium.org/7736003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prerender/prerender_browsertest.cc')
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc79
1 files changed, 28 insertions, 51 deletions
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index b91abe2..eab87f9 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -102,21 +102,19 @@ class TestPrerenderContents : public PrerenderContents {
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 @@ class TestPrerenderContents : public PrerenderContents {
// 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 @@ class TestPrerenderContents : public PrerenderContents {
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 @@ class WaitForLoadPrerenderContentsFactory : public PrerenderContents::Factory {
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 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
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 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
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 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
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,8 +657,23 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
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(
@@ -707,14 +710,6 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderVisibility) {
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 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderVisibilityBackgroundTab) {
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 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderVisibilityForegroundTab) {
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) {