OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 EXPECT_TRUE(WaitForLoadStop(shell2->web_contents())); | 446 EXPECT_TRUE(WaitForLoadStop(shell2->web_contents())); |
447 | 447 |
448 EXPECT_EQ(1, shell2->web_contents()->GetController().GetEntryCount()); | 448 EXPECT_EQ(1, shell2->web_contents()->GetController().GetEntryCount()); |
449 EXPECT_EQ(1, RendererHistoryLength(shell2)); | 449 EXPECT_EQ(1, RendererHistoryLength(shell2)); |
450 | 450 |
451 // Again, as above, there's no way to access the renderer's notion of the | 451 // Again, as above, there's no way to access the renderer's notion of the |
452 // history offset via JavaScript. Checking just the history length, again, | 452 // history offset via JavaScript. Checking just the history length, again, |
453 // will have to suffice. | 453 // will have to suffice. |
454 } | 454 } |
455 | 455 |
456 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | |
Charlie Reis
2016/05/13 19:14:31
Can you put a comment linking to https://crbug.com
Andrey Kraynov
2016/05/16 08:03:11
Done.
| |
457 PageIDUpdatedOnPageReplacement) { | |
458 NavigationController& controller = shell()->web_contents()->GetController(); | |
459 const GURL page_url = embedded_test_server()->GetURL( | |
460 "/navigation_controller/simple_page_1.html"); | |
461 | |
462 // Use data scheme first so that the next page will be loaded | |
463 // in a separate site instance. | |
464 NavigateToURL(shell(), GURL("data:text/html,page1")); | |
Charlie Reis
2016/05/13 19:14:31
nit: EXPECT_TRUE
Andrey Kraynov
2016/05/16 08:03:11
Done.
| |
465 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | |
Charlie Reis
2016/05/13 19:14:31
This isn't necessary, since NavigateToURL will wai
Andrey Kraynov
2016/05/16 08:03:11
Done.
| |
466 EXPECT_EQ(1, controller.GetEntryCount()); | |
467 EXPECT_NE(-1, shell()->web_contents()->GetMaxPageID()); | |
468 | |
469 // Now navigate and replace the current entry. | |
470 NavigateToURLAndReplace(shell(), page_url); | |
471 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | |
472 EXPECT_EQ(1, controller.GetEntryCount()); | |
473 | |
474 // Page ID should be updated. | |
475 EXPECT_NE(-1, shell()->web_contents()->GetMaxPageID()); | |
476 | |
477 // Reload the page and verify that we don't hit | |
478 // a DCHECK in |RenderFrameImpl::NavigateInternal|. | |
479 controller.Reload(false); | |
480 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | |
481 | |
482 // DCHECK shouldn't be triggered and we should have a valid page ID. | |
483 EXPECT_NE(-1, shell()->web_contents()->GetMaxPageID()); | |
Charlie Reis
2016/05/13 19:14:31
Also check EXPECT_TRUE(shell()->web_contents()->Ge
Andrey Kraynov
2016/05/16 08:03:11
Done.
| |
484 } | |
485 | |
456 namespace { | 486 namespace { |
457 | 487 |
458 class NoNavigationsObserver : public WebContentsObserver { | 488 class NoNavigationsObserver : public WebContentsObserver { |
459 public: | 489 public: |
460 // Observes navigation for the specified |web_contents|. | 490 // Observes navigation for the specified |web_contents|. |
461 explicit NoNavigationsObserver(WebContents* web_contents) | 491 explicit NoNavigationsObserver(WebContents* web_contents) |
462 : WebContentsObserver(web_contents) {} | 492 : WebContentsObserver(web_contents) {} |
463 | 493 |
464 private: | 494 private: |
465 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, | 495 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, |
(...skipping 3622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4088 // TODO(clamy): Check the post id as well when PlzNavigate handles it | 4118 // TODO(clamy): Check the post id as well when PlzNavigate handles it |
4089 // properly. | 4119 // properly. |
4090 if (!IsBrowserSideNavigationEnabled()) | 4120 if (!IsBrowserSideNavigationEnabled()) |
4091 EXPECT_NE(-1, frame_entry->post_id()); | 4121 EXPECT_NE(-1, frame_entry->post_id()); |
4092 EXPECT_FALSE(entry->GetHasPostData()); | 4122 EXPECT_FALSE(entry->GetHasPostData()); |
4093 EXPECT_EQ(-1, entry->GetPostID()); | 4123 EXPECT_EQ(-1, entry->GetPostID()); |
4094 } | 4124 } |
4095 } | 4125 } |
4096 | 4126 |
4097 } // namespace content | 4127 } // namespace content |
OLD | NEW |