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/renderer_host/render_widget_host_impl.h" | 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/browser/web_contents/web_contents_view.h" | 10 #include "content/browser/web_contents/web_contents_view.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 int loadingStateChangedCount() const { return loadingStateChangedCount_; } | 180 int loadingStateChangedCount() const { return loadingStateChangedCount_; } |
181 int loadingStateToDifferentDocumentCount() const { | 181 int loadingStateToDifferentDocumentCount() const { |
182 return loadingStateToDifferentDocumentCount_; | 182 return loadingStateToDifferentDocumentCount_; |
183 } | 183 } |
184 | 184 |
185 private: | 185 private: |
186 int loadingStateChangedCount_; | 186 int loadingStateChangedCount_; |
187 int loadingStateToDifferentDocumentCount_; | 187 int loadingStateToDifferentDocumentCount_; |
188 }; | 188 }; |
189 | 189 |
190 // See: http://crbug.com/298193 | |
191 #if defined(OS_WIN) || defined(OS_LINUX) | |
192 #define MAYBE_DidStopLoadingDetails DISABLED_DidStopLoadingDetails | |
193 #else | |
194 #define MAYBE_DidStopLoadingDetails DidStopLoadingDetails | |
195 #endif | |
196 | |
197 // Test that DidStopLoading includes the correct URL in the details. | |
198 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | |
199 MAYBE_DidStopLoadingDetails) { | |
200 ASSERT_TRUE(embedded_test_server()->Start()); | |
201 | |
202 LoadStopNotificationObserver load_observer( | |
203 &shell()->web_contents()->GetController()); | |
204 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | |
205 load_observer.Wait(); | |
206 | |
207 EXPECT_EQ("/title1.html", load_observer.url_.path()); | |
208 EXPECT_EQ(0, load_observer.session_index_); | |
209 EXPECT_EQ(&shell()->web_contents()->GetController(), | |
210 load_observer.controller_); | |
211 } | |
212 | |
213 // See: http://crbug.com/298193 | |
214 #if defined(OS_WIN) || defined(OS_LINUX) | |
215 #define MAYBE_DidStopLoadingDetailsWithPending \ | |
216 DISABLED_DidStopLoadingDetailsWithPending | |
217 #else | |
218 #define MAYBE_DidStopLoadingDetailsWithPending DidStopLoadingDetailsWithPending | |
219 #endif | |
220 | |
221 // Test that DidStopLoading includes the correct URL in the details when a | |
222 // pending entry is present. | |
223 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | |
224 MAYBE_DidStopLoadingDetailsWithPending) { | |
225 ASSERT_TRUE(embedded_test_server()->Start()); | |
226 GURL url("data:text/html,<div>test</div>"); | |
227 | |
228 // Listen for the first load to stop. | |
229 LoadStopNotificationObserver load_observer( | |
230 &shell()->web_contents()->GetController()); | |
231 // Start a new pending navigation as soon as the first load commits. | |
232 // We will hear a DidStopLoading from the first load as the new load | |
233 // is started. | |
234 NavigateOnCommitObserver commit_observer( | |
235 shell(), embedded_test_server()->GetURL("/title2.html")); | |
236 NavigateToURL(shell(), url); | |
237 load_observer.Wait(); | |
238 | |
239 EXPECT_EQ(url, load_observer.url_); | |
240 EXPECT_EQ(0, load_observer.session_index_); | |
241 EXPECT_EQ(&shell()->web_contents()->GetController(), | |
242 load_observer.controller_); | |
243 } | |
244 // Test that a renderer-initiated navigation to an invalid URL does not leave | 190 // Test that a renderer-initiated navigation to an invalid URL does not leave |
245 // around a pending entry that could be used in a URL spoof. We test this in | 191 // around a pending entry that could be used in a URL spoof. We test this in |
246 // a browser test because our unit test framework incorrectly calls | 192 // a browser test because our unit test framework incorrectly calls |
247 // DidStartProvisionalLoadForFrame for in-page navigations. | 193 // DidStartProvisionalLoadForFrame for in-page navigations. |
248 // See http://crbug.com/280512. | 194 // See http://crbug.com/280512. |
249 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 195 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
250 ClearNonVisiblePendingOnFail) { | 196 ClearNonVisiblePendingOnFail) { |
251 ASSERT_TRUE(embedded_test_server()->Start()); | 197 ASSERT_TRUE(embedded_test_server()->Start()); |
252 | 198 |
253 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | 199 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 Shell* new_shell = new_shell_observer.GetShell(); | 756 Shell* new_shell = new_shell_observer.GetShell(); |
811 WaitForLoadStop(new_shell->web_contents()); | 757 WaitForLoadStop(new_shell->web_contents()); |
812 | 758 |
813 EXPECT_EQ("foo", | 759 EXPECT_EQ("foo", |
814 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 760 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
815 ->GetFrameTree()->root()->frame_name()); | 761 ->GetFrameTree()->root()->frame_name()); |
816 } | 762 } |
817 } | 763 } |
818 | 764 |
819 } // namespace content | 765 } // namespace content |
OLD | NEW |