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

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

Issue 161113002: Fix pushState causing stop/reload button and favicon to flicker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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') | 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/strings/utf_string_conversions.h"
5 #include "base/values.h" 6 #include "base/values.h"
6 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/load_notification_details.h" 9 #include "content/public/browser/load_notification_details.h"
9 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
10 #include "content/public/browser/notification_details.h" 11 #include "content/public/browser/notification_details.h"
11 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/render_widget_host_view.h" 15 #include "content/public/browser/render_widget_host_view.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 143 }
143 144
144 gfx::Size rwhv_create_size() const { return rwhv_create_size_; } 145 gfx::Size rwhv_create_size() const { return rwhv_create_size_; }
145 146
146 private: 147 private:
147 Shell* shell_; // Weak ptr. 148 Shell* shell_; // Weak ptr.
148 gfx::Size wcv_new_size_; 149 gfx::Size wcv_new_size_;
149 gfx::Size rwhv_create_size_; 150 gfx::Size rwhv_create_size_;
150 }; 151 };
151 152
153 class LoadingStateChangedDelegate : public WebContentsDelegate {
154 public:
155 LoadingStateChangedDelegate()
156 : loadingStateChangedCount_(0)
157 , loadingStateToDifferentDocumentCount_(0) {
158 }
159
160 // WebContentsDelgate:
161 virtual void LoadingStateChanged(WebContents* contents,
162 bool to_different_document) OVERRIDE {
163 loadingStateChangedCount_++;
164 if (to_different_document)
165 loadingStateToDifferentDocumentCount_++;
166 }
167
168 int loadingStateChangedCount() const { return loadingStateChangedCount_; }
169 int loadingStateToDifferentDocumentCount() const {
170 return loadingStateToDifferentDocumentCount_;
171 }
172
173 private:
174 int loadingStateChangedCount_;
175 int loadingStateToDifferentDocumentCount_;
176 };
177
152 // See: http://crbug.com/298193 178 // See: http://crbug.com/298193
153 #if defined(OS_WIN) 179 #if defined(OS_WIN)
154 #define MAYBE_DidStopLoadingDetails DISABLED_DidStopLoadingDetails 180 #define MAYBE_DidStopLoadingDetails DISABLED_DidStopLoadingDetails
155 #else 181 #else
156 #define MAYBE_DidStopLoadingDetails DidStopLoadingDetails 182 #define MAYBE_DidStopLoadingDetails DidStopLoadingDetails
157 #endif 183 #endif
158 184
159 // Test that DidStopLoading includes the correct URL in the details. 185 // Test that DidStopLoading includes the correct URL in the details.
160 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, 186 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
161 MAYBE_DidStopLoadingDetails) { 187 MAYBE_DidStopLoadingDetails) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // Install the observer and navigate cross-site. 404 // Install the observer and navigate cross-site.
379 RenderFrameCreatedObserver observer(shell()); 405 RenderFrameCreatedObserver observer(shell());
380 NavigateToURL(shell(), cross_site_url); 406 NavigateToURL(shell(), cross_site_url);
381 407
382 // The observer should've seen a RenderFrameCreated call for the new frame 408 // The observer should've seen a RenderFrameCreated call for the new frame
383 // and not the old one. 409 // and not the old one.
384 EXPECT_NE(observer.last_rfh(), orig_rfh); 410 EXPECT_NE(observer.last_rfh(), orig_rfh);
385 EXPECT_EQ(observer.last_rfh(), shell()->web_contents()->GetMainFrame()); 411 EXPECT_EQ(observer.last_rfh(), shell()->web_contents()->GetMainFrame());
386 } 412 }
387 413
414 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
415 LoadingStateChangedForSameDocumentNavigation) {
416 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
417 scoped_ptr<LoadingStateChangedDelegate> delegate(
418 new LoadingStateChangedDelegate());
419 shell()->web_contents()->SetDelegate(delegate.get());
420
421 LoadStopNotificationObserver load_observer(
422 &shell()->web_contents()->GetController());
423 TitleWatcher title_watcher(shell()->web_contents(),
424 base::ASCIIToUTF16("pushState"));
425 NavigateToURL(shell(), embedded_test_server()->GetURL("/push_state.html"));
426 load_observer.Wait();
427 base::string16 title = title_watcher.WaitAndGetTitle();
428 ASSERT_EQ(title, base::ASCIIToUTF16("pushState"));
429
430 // LoadingStateChanged should be called 4 times: start and stop for the
431 // initial load of push_state.html, and start and stop for the "navigation"
432 // triggered by history.pushState(). However, the start notification for the
433 // history.pushState() navigation should set to_different_document to false.
434 EXPECT_EQ("pushState", shell()->web_contents()->GetURL().ref());
435 EXPECT_EQ(4, delegate->loadingStateChangedCount());
436 EXPECT_EQ(3, delegate->loadingStateToDifferentDocumentCount());
437 }
438
388 } // namespace content 439 } // 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