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) |
+{ |
+ 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 |