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

Unified Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 306033002: Update post state on navigation within page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test in debug Created 6 years, 7 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 | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_controller_impl_unittest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index 6afa917a14b3f08a3a644b0937f813b1e28a6944..f639026f9f18cdf16557aabaf0c3c70105b65303 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -235,21 +235,33 @@ SiteInstance* GetSiteInstanceFromEntry(NavigationEntry* entry) {
class TestWebContentsDelegate : public WebContentsDelegate {
public:
explicit TestWebContentsDelegate() :
- navigation_state_change_count_(0) {}
+ navigation_state_change_count_(0),
+ repost_form_warning_count_(0) {}
int navigation_state_change_count() {
return navigation_state_change_count_;
}
+ int repost_form_warning_count() {
+ return repost_form_warning_count_;
+ }
+
// Keep track of whether the tab has notified us of a navigation state change.
virtual void NavigationStateChanged(const WebContents* source,
unsigned changed_flags) OVERRIDE {
navigation_state_change_count_++;
}
+ virtual void ShowRepostFormWarningDialog(WebContents* source) OVERRIDE {
+ repost_form_warning_count_++;
+ }
+
private:
// The number of times NavigationStateChanged has been called.
int navigation_state_change_count_;
+
+ // The number of times ShowRepostFormWarningDialog() was called.
+ int repost_form_warning_count_;
};
// -----------------------------------------------------------------------------
@@ -4224,4 +4236,40 @@ TEST_F(NavigationControllerTest, ClearHistoryList) {
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
}
+TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
+ scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate());
+ EXPECT_FALSE(contents()->GetDelegate());
+ contents()->SetDelegate(delegate.get());
+
+ // Submit a form.
+ GURL url("http://foo");
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
+ params.page_id = 1;
+ params.url = url;
+ params.transition = PAGE_TRANSITION_FORM_SUBMIT;
+ params.gesture = NavigationGestureUser;
+ params.page_state = PageState::CreateFromURL(url);
+ params.was_within_same_page = false;
+ params.is_post = true;
+ params.post_id = 2;
+ test_rvh()->SendNavigateWithParams(&params);
+
+ // history.replaceState() is called.
+ GURL replace_url("http://foo#foo");
+ params.page_id = 1;
+ params.url = replace_url;
+ params.transition = PAGE_TRANSITION_LINK;
+ params.gesture = NavigationGestureUser;
+ params.page_state = PageState::CreateFromURL(replace_url);
+ params.was_within_same_page = true;
+ params.is_post = false;
+ params.post_id = -1;
+ test_rvh()->SendNavigateWithParams(&params);
+
+ // Now reload. replaceState overrides the POST, so we should not show a
+ // repost warning dialog.
+ controller_impl().Reload(true);
+ EXPECT_EQ(0, delegate->repost_form_warning_count());
+}
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698