OLD | NEW |
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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
9 #include "content/browser/web_contents/web_contents_view.h" | 9 #include "content/browser/web_contents/web_contents_view.h" |
10 #include "content/public/browser/load_notification_details.h" | 10 #include "content/public/browser/load_notification_details.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 shell_(shell), | 90 shell_(shell), |
91 url_(url), | 91 url_(url), |
92 done_(false) { | 92 done_(false) { |
93 } | 93 } |
94 | 94 |
95 // WebContentsObserver: | 95 // WebContentsObserver: |
96 virtual void NavigationEntryCommitted( | 96 virtual void NavigationEntryCommitted( |
97 const LoadCommittedDetails& load_details) OVERRIDE { | 97 const LoadCommittedDetails& load_details) OVERRIDE { |
98 if (!done_) { | 98 if (!done_) { |
99 done_ = true; | 99 done_ = true; |
| 100 shell_->Stop(); |
100 shell_->LoadURL(url_); | 101 shell_->LoadURL(url_); |
101 } | 102 } |
102 } | 103 } |
103 | 104 |
104 Shell* shell_; | 105 Shell* shell_; |
105 GURL url_; | 106 GURL url_; |
106 bool done_; | 107 bool done_; |
107 }; | 108 }; |
108 | 109 |
109 class RenderViewSizeDelegate : public WebContentsDelegate { | 110 class RenderViewSizeDelegate : public WebContentsDelegate { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 DISABLED_DidStopLoadingDetailsWithPending | 206 DISABLED_DidStopLoadingDetailsWithPending |
206 #else | 207 #else |
207 #define MAYBE_DidStopLoadingDetailsWithPending DidStopLoadingDetailsWithPending | 208 #define MAYBE_DidStopLoadingDetailsWithPending DidStopLoadingDetailsWithPending |
208 #endif | 209 #endif |
209 | 210 |
210 // Test that DidStopLoading includes the correct URL in the details when a | 211 // Test that DidStopLoading includes the correct URL in the details when a |
211 // pending entry is present. | 212 // pending entry is present. |
212 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 213 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
213 MAYBE_DidStopLoadingDetailsWithPending) { | 214 MAYBE_DidStopLoadingDetailsWithPending) { |
214 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 215 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 216 GURL url("data:text/html,<div>test</div>"); |
215 | 217 |
216 // Listen for the first load to stop. | 218 // Listen for the first load to stop. |
217 LoadStopNotificationObserver load_observer( | 219 LoadStopNotificationObserver load_observer( |
218 &shell()->web_contents()->GetController()); | 220 &shell()->web_contents()->GetController()); |
219 // Start a new pending navigation as soon as the first load commits. | 221 // Start a new pending navigation as soon as the first load commits. |
220 // We will hear a DidStopLoading from the first load as the new load | 222 // We will hear a DidStopLoading from the first load as the new load |
221 // is started. | 223 // is started. |
222 NavigateOnCommitObserver commit_observer( | 224 NavigateOnCommitObserver commit_observer( |
223 shell(), embedded_test_server()->GetURL("/title2.html")); | 225 shell(), embedded_test_server()->GetURL("/title2.html")); |
224 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | 226 NavigateToURL(shell(), url); |
225 load_observer.Wait(); | 227 load_observer.Wait(); |
226 | 228 |
227 EXPECT_EQ("/title1.html", load_observer.url_.path()); | 229 EXPECT_EQ(url, load_observer.url_); |
228 EXPECT_EQ(0, load_observer.session_index_); | 230 EXPECT_EQ(0, load_observer.session_index_); |
229 EXPECT_EQ(&shell()->web_contents()->GetController(), | 231 EXPECT_EQ(&shell()->web_contents()->GetController(), |
230 load_observer.controller_); | 232 load_observer.controller_); |
231 } | 233 } |
232 // Test that a renderer-initiated navigation to an invalid URL does not leave | 234 // Test that a renderer-initiated navigation to an invalid URL does not leave |
233 // around a pending entry that could be used in a URL spoof. We test this in | 235 // around a pending entry that could be used in a URL spoof. We test this in |
234 // a browser test because our unit test framework incorrectly calls | 236 // a browser test because our unit test framework incorrectly calls |
235 // DidStartProvisionalLoadForFrame for in-page navigations. | 237 // DidStartProvisionalLoadForFrame for in-page navigations. |
236 // See http://crbug.com/280512. | 238 // See http://crbug.com/280512. |
237 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 239 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 } | 512 } |
511 | 513 |
512 // ... and the last one should be 1.0, meaning complete. | 514 // ... and the last one should be 1.0, meaning complete. |
513 ASSERT_GE(progresses.size(), 1U) | 515 ASSERT_GE(progresses.size(), 1U) |
514 << "There should be at least one progress update"; | 516 << "There should be at least one progress update"; |
515 EXPECT_EQ(1.0, *progresses.rbegin()); | 517 EXPECT_EQ(1.0, *progresses.rbegin()); |
516 } | 518 } |
517 | 519 |
518 } // namespace content | 520 } // namespace content |
519 | 521 |
OLD | NEW |