| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/browser/frame_host/frame_navigation_entry.h" | 8 #include "content/browser/frame_host/frame_navigation_entry.h" |
| 9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
| 10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // that the browser and renderer agree, and that both get it right. | 179 // that the browser and renderer agree, and that both get it right. |
| 180 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 180 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 181 CorrectLengthWithCurrentItemReplacement) { | 181 CorrectLengthWithCurrentItemReplacement) { |
| 182 NavigationController& controller = | 182 NavigationController& controller = |
| 183 shell()->web_contents()->GetController(); | 183 shell()->web_contents()->GetController(); |
| 184 | 184 |
| 185 EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,page1"))); | 185 EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,page1"))); |
| 186 EXPECT_EQ(1, controller.GetEntryCount()); | 186 EXPECT_EQ(1, controller.GetEntryCount()); |
| 187 EXPECT_EQ(1, RendererHistoryLength(shell())); | 187 EXPECT_EQ(1, RendererHistoryLength(shell())); |
| 188 | 188 |
| 189 EXPECT_TRUE(NavigateToURLAndReplace(shell(), GURL("data:text/html,page2"))); | 189 EXPECT_TRUE(NavigateToURLAndReplace(shell(), GURL("data:text/html,page1a"))); |
| 190 EXPECT_EQ(1, controller.GetEntryCount()); | 190 EXPECT_EQ(1, controller.GetEntryCount()); |
| 191 EXPECT_EQ(1, RendererHistoryLength(shell())); | 191 EXPECT_EQ(1, RendererHistoryLength(shell())); |
| 192 | 192 |
| 193 // Now create two more entries and go back, to test replacing an entry without |
| 194 // pruning the forward history. |
| 195 EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,page2"))); |
| 196 EXPECT_EQ(2, controller.GetEntryCount()); |
| 197 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 198 |
| 199 EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,page3"))); |
| 200 EXPECT_EQ(3, controller.GetEntryCount()); |
| 201 EXPECT_EQ(3, RendererHistoryLength(shell())); |
| 202 |
| 203 controller.GoBack(); |
| 204 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 205 controller.GoBack(); |
| 206 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 207 EXPECT_TRUE(controller.CanGoForward()); |
| 208 |
| 209 EXPECT_TRUE(NavigateToURLAndReplace(shell(), GURL("data:text/html,page1b"))); |
| 210 EXPECT_EQ(3, controller.GetEntryCount()); |
| 211 EXPECT_EQ(3, RendererHistoryLength(shell())); |
| 212 EXPECT_TRUE(controller.CanGoForward()); |
| 213 |
| 193 // Note that there's no way to access the renderer's notion of the history | 214 // Note that there's no way to access the renderer's notion of the history |
| 194 // offset via JavaScript. Checking just the history length, though, is enough; | 215 // offset via JavaScript. Checking just the history length, though, is enough; |
| 195 // if the replacement failed, there would be a new history entry and thus an | 216 // if the replacement failed, there would be a new history entry and thus an |
| 196 // incorrect length. | 217 // incorrect length. |
| 197 } | 218 } |
| 198 | 219 |
| 199 // When spawning a new page from a WebUI page, make sure that the browser and | 220 // When spawning a new page from a WebUI page, make sure that the browser and |
| 200 // renderer agree about the length of the history list, and that both get it | 221 // renderer agree about the length of the history list, and that both get it |
| 201 // right. | 222 // right. |
| 202 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 223 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| (...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 // tricky. | 2145 // tricky. |
| 2125 EXPECT_EQ(nullptr, controller.GetPendingEntry()); | 2146 EXPECT_EQ(nullptr, controller.GetPendingEntry()); |
| 2126 shell()->web_contents()->Stop(); | 2147 shell()->web_contents()->Stop(); |
| 2127 watcher.Wait(); | 2148 watcher.Wait(); |
| 2128 } | 2149 } |
| 2129 | 2150 |
| 2130 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 2151 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
| 2131 } | 2152 } |
| 2132 | 2153 |
| 2133 } // namespace content | 2154 } // namespace content |
| OLD | NEW |