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

Side by Side Diff: content/browser/web_contents/web_contents_impl_browsertest.cc

Issue 23978003: Delete unneeded pending entries in DidFailProvisionalLoad to prevent a spoof. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only clear the pending entry, not the transient. Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_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/values.h" 5 #include "base/values.h"
6 #include "content/browser/renderer_host/render_view_host_impl.h" 6 #include "content/browser/renderer_host/render_view_host_impl.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/load_notification_details.h" 8 #include "content/public/browser/load_notification_details.h"
9 #include "content/public/browser/navigation_controller.h" 9 #include "content/public/browser/navigation_controller.h"
10 #include "content/public/browser/notification_details.h" 10 #include "content/public/browser/notification_details.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 NavigateOnCommitObserver commit_observer( 178 NavigateOnCommitObserver commit_observer(
179 shell(), embedded_test_server()->GetURL("/title2.html")); 179 shell(), embedded_test_server()->GetURL("/title2.html"));
180 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 180 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
181 load_observer.Wait(); 181 load_observer.Wait();
182 182
183 EXPECT_EQ("/title1.html", load_observer.url_.path()); 183 EXPECT_EQ("/title1.html", load_observer.url_.path());
184 EXPECT_EQ(0, load_observer.session_index_); 184 EXPECT_EQ(0, load_observer.session_index_);
185 EXPECT_EQ(&shell()->web_contents()->GetController(), 185 EXPECT_EQ(&shell()->web_contents()->GetController(),
186 load_observer.controller_); 186 load_observer.controller_);
187 } 187 }
188 // Test that a renderer-initiated navigation to an invalid URL does not leave
189 // around a pending entry that could be used in a URL spoof. We test this in
190 // a browser test because our unit test framework incorrectly calls
191 // DidStartProvisionalLoadForFrame for in-page navigations.
192 // See http://crbug.com/280512.
193 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
194 ClearNonVisiblePendingOnFail) {
195 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
196
197 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
198
199 // Navigate to an invalid URL and make sure it doesn't leave a pending entry.
200 LoadStopNotificationObserver load_observer1(
201 &shell()->web_contents()->GetController());
202 ASSERT_TRUE(ExecuteScript(shell()->web_contents(),
203 "window.location.href=\"nonexistent:12121\";"));
204 load_observer1.Wait();
205 EXPECT_FALSE(shell()->web_contents()->GetController().GetPendingEntry());
206
207 LoadStopNotificationObserver load_observer2(
208 &shell()->web_contents()->GetController());
209 ASSERT_TRUE(ExecuteScript(shell()->web_contents(),
210 "window.location.href=\"#foo\";"));
211 load_observer2.Wait();
212 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html#foo"),
213 shell()->web_contents()->GetVisibleURL());
214 }
188 215
189 // Test that the browser receives the proper frame attach/detach messages from 216 // Test that the browser receives the proper frame attach/detach messages from
190 // the renderer and builds proper frame tree. 217 // the renderer and builds proper frame tree.
191 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, FrameTree) { 218 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, FrameTree) {
192 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 219 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
193 220
194 NavigateToURL(shell(), 221 NavigateToURL(shell(),
195 embedded_test_server()->GetURL("/frame_tree/top.html")); 222 embedded_test_server()->GetURL("/frame_tree/top.html"));
196 223
197 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); 224 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // RenderViewSizeObserver resizes WebContentsView in NavigateToPendingEntry, 303 // RenderViewSizeObserver resizes WebContentsView in NavigateToPendingEntry,
277 // so both WebContentsView and RenderWidgetHostView adopt this new size. 304 // so both WebContentsView and RenderWidgetHostView adopt this new size.
278 new_size.Enlarge(size_insets.width(), size_insets.height()); 305 new_size.Enlarge(size_insets.width(), size_insets.height());
279 EXPECT_EQ(new_size, 306 EXPECT_EQ(new_size,
280 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). 307 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds().
281 size()); 308 size());
282 EXPECT_EQ(new_size, shell()->web_contents()->GetView()->GetContainerSize()); 309 EXPECT_EQ(new_size, shell()->web_contents()->GetView()->GetContainerSize());
283 } 310 }
284 311
285 } // namespace content 312 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698