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

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

Issue 1545973002: Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reenabled 2 tests Created 4 years, 11 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.h » ('j') | 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/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_impl.h" 10 #include "content/browser/renderer_host/render_widget_host_impl.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 shell_(shell), 101 shell_(shell),
102 url_(url), 102 url_(url),
103 done_(false) { 103 done_(false) {
104 } 104 }
105 105
106 // WebContentsObserver: 106 // WebContentsObserver:
107 void NavigationEntryCommitted( 107 void NavigationEntryCommitted(
108 const LoadCommittedDetails& load_details) override { 108 const LoadCommittedDetails& load_details) override {
109 if (!done_) { 109 if (!done_) {
110 done_ = true; 110 done_ = true;
111 shell_->LoadURL(url_);
112
113 // There should be a pending entry.
114 CHECK(shell_->web_contents()->GetController().GetPendingEntry());
115
116 // Now that there is a pending entry, stop the load.
111 shell_->Stop(); 117 shell_->Stop();
112 shell_->LoadURL(url_);
113 } 118 }
114 } 119 }
115 120
116 Shell* shell_; 121 Shell* shell_;
117 GURL url_; 122 GURL url_;
118 bool done_; 123 bool done_;
119 }; 124 };
120 125
121 class RenderViewSizeDelegate : public WebContentsDelegate { 126 class RenderViewSizeDelegate : public WebContentsDelegate {
122 public: 127 public:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 int loadingStateChangedCount() const { return loadingStateChangedCount_; } 187 int loadingStateChangedCount() const { return loadingStateChangedCount_; }
183 int loadingStateToDifferentDocumentCount() const { 188 int loadingStateToDifferentDocumentCount() const {
184 return loadingStateToDifferentDocumentCount_; 189 return loadingStateToDifferentDocumentCount_;
185 } 190 }
186 191
187 private: 192 private:
188 int loadingStateChangedCount_; 193 int loadingStateChangedCount_;
189 int loadingStateToDifferentDocumentCount_; 194 int loadingStateToDifferentDocumentCount_;
190 }; 195 };
191 196
192 // See: http://crbug.com/298193
193 #if defined(OS_WIN) || defined(OS_LINUX)
194 #define MAYBE_DidStopLoadingDetails DISABLED_DidStopLoadingDetails
195 #else
196 #define MAYBE_DidStopLoadingDetails DidStopLoadingDetails
197 #endif
198
199 // Test that DidStopLoading includes the correct URL in the details. 197 // Test that DidStopLoading includes the correct URL in the details.
200 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, 198 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, DidStopLoadingDetails) {
clamy 2016/01/25 14:01:18 It appears that the patch fixed the flakyness on t
201 MAYBE_DidStopLoadingDetails) {
202 ASSERT_TRUE(embedded_test_server()->Start()); 199 ASSERT_TRUE(embedded_test_server()->Start());
203 200
204 LoadStopNotificationObserver load_observer( 201 LoadStopNotificationObserver load_observer(
205 &shell()->web_contents()->GetController()); 202 &shell()->web_contents()->GetController());
206 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 203 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
207 load_observer.Wait(); 204 load_observer.Wait();
208 205
209 EXPECT_EQ("/title1.html", load_observer.url_.path()); 206 EXPECT_EQ("/title1.html", load_observer.url_.path());
210 EXPECT_EQ(0, load_observer.session_index_); 207 EXPECT_EQ(0, load_observer.session_index_);
211 EXPECT_EQ(&shell()->web_contents()->GetController(), 208 EXPECT_EQ(&shell()->web_contents()->GetController(),
212 load_observer.controller_); 209 load_observer.controller_);
213 } 210 }
214 211
215 // See: http://crbug.com/298193
216 #if defined(OS_WIN) || defined(OS_LINUX)
217 #define MAYBE_DidStopLoadingDetailsWithPending \
218 DISABLED_DidStopLoadingDetailsWithPending
219 #else
220 #define MAYBE_DidStopLoadingDetailsWithPending DidStopLoadingDetailsWithPending
221 #endif
222
223 // Test that DidStopLoading includes the correct URL in the details when a 212 // Test that DidStopLoading includes the correct URL in the details when a
224 // pending entry is present. 213 // pending entry is present.
225 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, 214 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
226 MAYBE_DidStopLoadingDetailsWithPending) { 215 DidStopLoadingDetailsWithPending) {
clamy 2016/01/25 14:01:18 Same here, but I had to rewrite part of the test t
nasko 2016/01/26 01:34:27 Should there be a TODO to cover this case or do yo
clamy 2016/01/28 13:52:21 I added a TODO not to forget about it.
227 ASSERT_TRUE(embedded_test_server()->Start()); 216 ASSERT_TRUE(embedded_test_server()->Start());
228 GURL url("data:text/html,<div>test</div>"); 217 GURL url1 = embedded_test_server()->GetURL("/title1.html");
218 GURL url2 = embedded_test_server()->GetURL("/title2.html");
229 219
230 // Listen for the first load to stop. 220 // Listen for the first load to stop.
231 LoadStopNotificationObserver load_observer( 221 LoadStopNotificationObserver load_observer(
232 &shell()->web_contents()->GetController()); 222 &shell()->web_contents()->GetController());
233 // Start a new pending navigation as soon as the first load commits. 223 // Start a new pending navigation as soon as the first load commits.
234 // We will hear a DidStopLoading from the first load as the new load 224 // We will hear a DidStopLoading from the first load as the new load
235 // is started. 225 // is started.
236 NavigateOnCommitObserver commit_observer( 226 NavigateOnCommitObserver commit_observer(
237 shell(), embedded_test_server()->GetURL("/title2.html")); 227 shell(), url2);
238 NavigateToURL(shell(), url); 228 NavigateToURL(shell(), url1);
239 load_observer.Wait(); 229 load_observer.Wait();
240 230
241 EXPECT_EQ(url, load_observer.url_); 231 EXPECT_EQ(url1, load_observer.url_);
242 EXPECT_EQ(0, load_observer.session_index_); 232 EXPECT_EQ(0, load_observer.session_index_);
243 EXPECT_EQ(&shell()->web_contents()->GetController(), 233 EXPECT_EQ(&shell()->web_contents()->GetController(),
244 load_observer.controller_); 234 load_observer.controller_);
245 } 235 }
246 // Test that a renderer-initiated navigation to an invalid URL does not leave 236 // Test that a renderer-initiated navigation to an invalid URL does not leave
247 // around a pending entry that could be used in a URL spoof. We test this in 237 // around a pending entry that could be used in a URL spoof. We test this in
248 // a browser test because our unit test framework incorrectly calls 238 // a browser test because our unit test framework incorrectly calls
249 // DidStartProvisionalLoadForFrame for in-page navigations. 239 // DidStartProvisionalLoadForFrame for in-page navigations.
250 // See http://crbug.com/280512. 240 // See http://crbug.com/280512.
251 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, 241 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 Shell* new_shell = new_shell_observer.GetShell(); 802 Shell* new_shell = new_shell_observer.GetShell();
813 WaitForLoadStop(new_shell->web_contents()); 803 WaitForLoadStop(new_shell->web_contents());
814 804
815 EXPECT_EQ("foo", 805 EXPECT_EQ("foo",
816 static_cast<WebContentsImpl*>(new_shell->web_contents()) 806 static_cast<WebContentsImpl*>(new_shell->web_contents())
817 ->GetFrameTree()->root()->frame_name()); 807 ->GetFrameTree()->root()->frame_name());
818 } 808 }
819 } 809 }
820 810
821 } // namespace content 811 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698