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

Unified Diff: content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc

Issue 2102283002: Gesture Nav: Protect against the case when navigation completes as soon as it is requested. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/aura/overscroll_navigation_overlay.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
index 69777ebde7e6894aae24b5b622ee1885d5f86573..f5cb27a6fb16353132300b763f352669d5052008 100644
--- a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
+++ b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
@@ -31,6 +31,29 @@
namespace content {
+// Forces web contents to complete web page load as soon as navigation starts.
+class ImmediateLoadObserver : WebContentsObserver {
+ public:
+ explicit ImmediateLoadObserver(TestWebContents* contents)
+ : contents_(contents) {
+ Observe(contents);
+ }
+ ~ImmediateLoadObserver() override {}
+
+ void DidStartNavigationToPendingEntry(
+ const GURL& url,
+ NavigationController::ReloadType reload_type) override {
+ // Simulate immediate web page load.
+ contents_->TestSetIsLoading(false);
+ Observe(nullptr);
+ }
+
+ private:
+ TestWebContents* contents_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImmediateLoadObserver);
+};
+
// A subclass of TestWebContents that offers a fake content window.
class OverscrollTestWebContents : public TestWebContents {
public:
@@ -331,6 +354,18 @@ TEST_F(OverscrollNavigationOverlayTest, CloseDuringAnimation) {
// Ensure a clean close.
}
+// Tests that we can handle the case when the load completes as soon as the
+// navigation is started.
+TEST_F(OverscrollNavigationOverlayTest, ImmediateLoadOnNavigate) {
+ PerformBackNavigationViaSliderCallbacks();
+ // This observer will force the page load to complete as soon as the
+ // navigation starts.
+ ImmediateLoadObserver immediate_nav(contents());
+ GetOverlay()->owa_->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST);
+ // This will start and immediately complete the navigation.
+ GetOverlay()->owa_->OnOverscrollComplete(OVERSCROLL_EAST);
+ EXPECT_FALSE(GetOverlay()->window_.get());
+}
// Tests that swapping the overlay window at the end of a gesture caused by the
// start of a new overscroll does not crash and the events still reach the new
« no previous file with comments | « content/browser/web_contents/aura/overscroll_navigation_overlay.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698