diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 23:34:03 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 23:34:03 +0000 |
commit | f890108d79ed124f122b1e2526866e0e96410ff9 (patch) | |
tree | a7cb6a7e96646af30f8935d3638c20662e7cbe57 | |
parent | 8922de5133af29b6d89830f5df893b3eccf3c7c1 (diff) | |
download | chromium_src-f890108d79ed124f122b1e2526866e0e96410ff9.zip chromium_src-f890108d79ed124f122b1e2526866e0e96410ff9.tar.gz chromium_src-f890108d79ed124f122b1e2526866e0e96410ff9.tar.bz2 |
This fixes the VerifyHistoryLength ui test flakiness. The test initiates page navigations in timers and reads the history length to validate it.
When we receive a request to initiate a navigation in the browser, we send out the request to the renderer and then immediately read the history length and send it out in an update history length request. This causes the test to fail at times as it reads a stale history length.
When we receive the DidAddHistoryItem notification in the renderer, we should not update the history length for the start page navigation. This results in the test failure at times as it reads an incorrect history length.
R=jam
Review URL: http://codereview.chromium.org/8898
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4344 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/render_view_host.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 15 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test1.html | 6 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test2.html | 5 |
4 files changed, 20 insertions, 8 deletions
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc index db87871..08addb5 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -180,8 +180,6 @@ void RenderViewHost::NavigateToEntry(const NavigationEntry& entry, process()->host_id(), params.url); DoNavigate(new ViewMsg_Navigate(routing_id_, params)); - - UpdateBackForwardListCount(); } void RenderViewHost::NavigateToURL(const GURL& url) { diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 094fcfe..e283499 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -2641,6 +2641,21 @@ void RenderView::TransitionToCommittedForNewPage() { } void RenderView::DidAddHistoryItem() { + // We don't want to update the history length for the start page + // navigation. + WebFrame* main_frame = webview()->GetMainFrame(); + DCHECK(main_frame != NULL); + + WebDataSource* ds = main_frame->GetDataSource(); + DCHECK(ds != NULL); + + const WebRequest& request = ds->GetRequest(); + RenderViewExtraRequestData* extra_data = + static_cast<RenderViewExtraRequestData*>(request.GetExtraData()); + + if (extra_data && extra_data->transition_type == PageTransition::START_PAGE) + return; + history_back_list_count_++; history_forward_list_count_ = 0; } diff --git a/chrome/test/data/History/history_length_test1.html b/chrome/test/data/History/history_length_test1.html index 4a44fa9..5700661 100644 --- a/chrome/test/data/History/history_length_test1.html +++ b/chrome/test/data/History/history_length_test1.html @@ -23,7 +23,7 @@ function onLoad() { return true; } - setTimeout(OnNavigateToPage2, 100); + setTimeout(OnNavigateToPage2, 100); return true; } @@ -42,7 +42,7 @@ function OnValidateHistoryForSecondRun() { function OnMoveForwardInHistory() { if (window.history.length != 2) { - onFailure("History_Length_Test", 1, "History length mismatch"); + onFailure("History_Length_Test", 1, "History length mismatch in MoveForward navigation"); return false; } @@ -53,7 +53,7 @@ function OnMoveForwardInHistory() { function OnNavigateToPage2() { if (window.history.length != 2) { - onFailure("History_Length_Test", 1, "History length mismatch"); + onFailure("History_Length_Test", 1, "History length mismatch in initial navigation"); return false; } diff --git a/chrome/test/data/History/history_length_test2.html b/chrome/test/data/History/history_length_test2.html index 2bae3ac..39b5ebc 100644 --- a/chrome/test/data/History/history_length_test2.html +++ b/chrome/test/data/History/history_length_test2.html @@ -11,13 +11,12 @@ History test2.... <SCRIPT type="text/javascript"> function onLoad() { - setTimeout(OnValidateHistoryLength, 100); + setTimeout(OnValidateHistoryLength, 100); } function OnValidateHistoryLength() { if (window.history.length != 3) { - onFailure("History_Length_Test", 1, "History length mismatch"); - alert(window.history.length); + onFailure("History_Length_Test", 1, "History length mismatch in second page OnLoad"); return false; } |