| 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(¶ms);
|
| +
|
| + // 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(¶ms);
|
| +
|
| + // 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
|
|
|