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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 917043004: Mark error pages as such on Ctrl-Shift-T reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 12 matching lines...) Expand all
23 #include "content/common/frame_messages.h" 23 #include "content/common/frame_messages.h"
24 #include "content/common/view_messages.h" 24 #include "content/common/view_messages.h"
25 #include "content/public/browser/navigation_details.h" 25 #include "content/public/browser/navigation_details.h"
26 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
27 #include "content/public/browser/notification_types.h" 27 #include "content/public/browser/notification_types.h"
28 #include "content/public/browser/render_view_host.h" 28 #include "content/public/browser/render_view_host.h"
29 #include "content/public/browser/web_contents_delegate.h" 29 #include "content/public/browser/web_contents_delegate.h"
30 #include "content/public/browser/web_contents_observer.h" 30 #include "content/public/browser/web_contents_observer.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "content/public/common/page_state.h" 32 #include "content/public/common/page_state.h"
33 #include "content/public/common/page_type.h"
33 #include "content/public/common/url_constants.h" 34 #include "content/public/common/url_constants.h"
34 #include "content/public/test/mock_render_process_host.h" 35 #include "content/public/test/mock_render_process_host.h"
35 #include "content/public/test/test_notification_tracker.h" 36 #include "content/public/test/test_notification_tracker.h"
36 #include "content/public/test/test_utils.h" 37 #include "content/public/test/test_utils.h"
37 #include "content/test/test_render_frame_host.h" 38 #include "content/test/test_render_frame_host.h"
38 #include "content/test/test_render_view_host.h" 39 #include "content/test/test_render_view_host.h"
39 #include "content/test/test_web_contents.h" 40 #include "content/test/test_web_contents.h"
40 #include "net/base/net_util.h" 41 #include "net/base/net_util.h"
41 #include "skia/ext/platform_canvas.h" 42 #include "skia/ext/platform_canvas.h"
42 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 4484 matching lines...) Expand 10 before | Expand all | Expand 10 after
4527 params.is_post = false; 4528 params.is_post = false;
4528 params.post_id = -1; 4529 params.post_id = -1;
4529 contents()->GetMainFrame()->SendNavigateWithParams(&params); 4530 contents()->GetMainFrame()->SendNavigateWithParams(&params);
4530 4531
4531 // Now reload. replaceState overrides the POST, so we should not show a 4532 // Now reload. replaceState overrides the POST, so we should not show a
4532 // repost warning dialog. 4533 // repost warning dialog.
4533 controller_impl().Reload(true); 4534 controller_impl().Reload(true);
4534 EXPECT_EQ(0, delegate->repost_form_warning_count()); 4535 EXPECT_EQ(0, delegate->repost_form_warning_count());
4535 } 4536 }
4536 4537
4538 TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
4539 GURL url("http://foo");
4540 FrameHostMsg_DidCommitProvisionalLoad_Params params;
4541 params.page_id = 1;
4542 params.url = url;
4543 params.transition = ui::PAGE_TRANSITION_LINK;
4544 params.gesture = NavigationGestureUser;
4545 params.page_state = PageState::CreateFromURL(url);
4546 params.was_within_same_page = false;
4547 params.is_post = true;
4548 params.post_id = 2;
4549 params.url_is_unreachable = true;
4550 // Navigate to new page
4551 {
4552 LoadCommittedDetails details;
4553 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
4554 EXPECT_EQ(PAGE_TYPE_ERROR,
4555 controller_impl().GetLastCommittedEntry()->GetPageType());
4556 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, details.type);
4557 }
4558
4559 // Navigate to existing page.
4560 {
4561 LoadCommittedDetails details;
4562 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
4563 EXPECT_EQ(PAGE_TYPE_ERROR,
4564 controller_impl().GetLastCommittedEntry()->GetPageType());
4565 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, details.type);
4566 }
4567
4568 // Navigate to same page.
4569 // Note: The call to LoadURL() creates a pending entry in order to trigger the
4570 // same-page transition.
4571 controller_impl().LoadURL(
4572 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
4573 params.transition = ui::PAGE_TRANSITION_TYPED;
4574 {
4575 LoadCommittedDetails details;
4576 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
4577 EXPECT_EQ(PAGE_TYPE_ERROR,
4578 controller_impl().GetLastCommittedEntry()->GetPageType());
4579 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, details.type);
4580 }
4581
4582 // Navigate in page.
4583 params.url = GURL("http://foo#foo");
4584 params.transition = ui::PAGE_TRANSITION_LINK;
4585 params.was_within_same_page = true;
4586 {
4587 LoadCommittedDetails details;
4588 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
4589 EXPECT_EQ(PAGE_TYPE_ERROR,
4590 controller_impl().GetLastCommittedEntry()->GetPageType());
4591 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type);
4592 }
4593 }
4594
4537 } // namespace content 4595 } // namespace content
OLDNEW
« 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