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(NavigateToURL(shell(), GURL("data:text/html,page2"))); |
190 EXPECT_EQ(1, controller.GetEntryCount()); | 190 EXPECT_EQ(2, controller.GetEntryCount()); |
191 EXPECT_EQ(1, RendererHistoryLength(shell())); | 191 EXPECT_EQ(2, RendererHistoryLength(shell())); |
192 | |
193 // Go back and then replace the first entry. | |
194 controller.GoBack(); | |
195 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | |
196 EXPECT_TRUE(controller.CanGoForward()); | |
197 | |
198 EXPECT_TRUE(NavigateToURLAndReplace(shell(), GURL("data:text/html,page1b"))); | |
199 EXPECT_EQ(2, controller.GetEntryCount()); | |
200 EXPECT_EQ(2, RendererHistoryLength(shell())); | |
201 EXPECT_TRUE(controller.CanGoForward()); | |
Avi (use Gerrit)
2015/07/16 20:00:16
Are you sure that this change keeps testing the sa
Charlie Reis
2015/07/16 20:17:43
Good point. The fact that I only had one addition
| |
192 | 202 |
193 // Note that there's no way to access the renderer's notion of the history | 203 // 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; | 204 // 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 | 205 // if the replacement failed, there would be a new history entry and thus an |
196 // incorrect length. | 206 // incorrect length. |
197 } | 207 } |
198 | 208 |
199 // When spawning a new page from a WebUI page, make sure that the browser and | 209 // 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 | 210 // renderer agree about the length of the history list, and that both get it |
201 // right. | 211 // right. |
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2124 // tricky. | 2134 // tricky. |
2125 EXPECT_EQ(nullptr, controller.GetPendingEntry()); | 2135 EXPECT_EQ(nullptr, controller.GetPendingEntry()); |
2126 shell()->web_contents()->Stop(); | 2136 shell()->web_contents()->Stop(); |
2127 watcher.Wait(); | 2137 watcher.Wait(); |
2128 } | 2138 } |
2129 | 2139 |
2130 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 2140 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
2131 } | 2141 } |
2132 | 2142 |
2133 } // namespace content | 2143 } // namespace content |
OLD | NEW |