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 0840d8c1b77fabff9833895c78e37f803c92c267..5801086b7986c9ec458142638bfec882042a01e8 100644 |
--- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
@@ -89,6 +89,7 @@ |
#include "public/web/WebFrameContentDumper.h" |
#include "public/web/WebHitTestResult.h" |
#include "public/web/WebInputMethodController.h" |
+#include "public/web/WebPrintParams.h" |
#include "public/web/WebScriptSource.h" |
#include "public/web/WebSettings.h" |
#include "public/web/WebTreeScopeType.h" |
@@ -4283,4 +4284,33 @@ TEST_P(WebViewTest, ViewportOverrideAdaptsToScaleAndScroll) { |
*devToolsEmulator->visibleContentRectForPainting()); |
} |
+TEST_P(WebViewTest, ResizeForPrintingViewportUnits) { |
+ WebViewImpl* webView = m_webViewHelper.initialize(); |
+ webView->resize(WebSize(800, 600)); |
+ |
+ WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
+ FrameTestHelpers::loadHTMLString(webView->mainFrame(), |
+ "<style>#vw { width: 100vw }</style>" |
+ "<div id=vw></div>", |
+ baseURL); |
+ |
+ WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
+ Document* document = frame->frame()->document(); |
+ Element* vwElement = document->getElementById("vw"); |
+ |
+ EXPECT_EQ(800, vwElement->offsetWidth()); |
+ |
+ WebPrintParams printParams; |
+ printParams.printContentArea.width = 500; |
+ printParams.printContentArea.height = 500; |
+ |
+ frame->printBegin(printParams, WebNode()); |
+ webView->resize(WebSize(500, 500)); |
+ EXPECT_EQ(500, vwElement->offsetWidth()); |
+ |
+ webView->resize(WebSize(800, 600)); |
+ frame->printEnd(); |
+ EXPECT_EQ(800, vwElement->offsetWidth()); |
+} |
+ |
} // namespace blink |