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

Unified Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2174263002: Defer loads in new pages/frames if ScopedPageLoadDeferral is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hammer Created 4 years, 5 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
Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
index 6437329f7f06772f2324d1d93a137b3d4f4bc0bf..ed6a2eae15a0e18c8c0eba543e8a27344813f747 100644
--- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
@@ -50,6 +50,7 @@
#include "core/loader/DocumentLoader.h"
#include "core/loader/FrameLoadRequest.h"
#include "core/page/Page.h"
+#include "core/page/ScopedPageLoadDeferrer.h"
#include "core/paint/PaintLayer.h"
#include "core/paint/PaintLayerPainter.h"
#include "core/timing/DOMWindowPerformance.h"
@@ -3216,4 +3217,42 @@ TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture)
frame->setAutofillClient(0);
}
+// Verify that a WebView created with a ScopedPageLoadDeferrer already on the
+// stack defers its loads.
+TEST_F(WebViewTest, CreatedDuringLoadDeferral)
+{
+ {
+ WebViewImpl* webView = m_webViewHelper.initialize();
+ EXPECT_FALSE(webView->page()->defersLoading());
+ }
+
+ {
+ ScopedPageLoadDeferrer deferrer;
+ WebViewImpl* webView = m_webViewHelper.initialize();
+ EXPECT_TRUE(webView->page()->defersLoading());
+ }
+}
+
+// Verify that page loads are deferred until all ScopedPageLoadDeferrers are
+// destroyed.
+TEST_F(WebViewTest, NestedLoadDeferrals)
dcheng 2016/07/25 06:48:18 I haven't figured out why, but this test (unexpect
+{
+ WebViewImpl* webView = m_webViewHelper.initialize();
+ EXPECT_FALSE(webView->page()->defersLoading());
+
+ {
+ ScopedPageLoadDeferrer deferrer;
+ EXPECT_TRUE(webView->page()->defersLoading());
+
+ {
+ ScopedPageLoadDeferrer deferrer2;
+ EXPECT_TRUE(webView->page()->defersLoading());
+ }
+
+ EXPECT_TRUE(webView->page()->defersLoading());
+ }
+
+ EXPECT_FALSE(webView->page()->defersLoading());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698