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

Unified Diff: Source/web/tests/PinchViewportTest.cpp

Issue 1094673002: Make window.innerWidth and innerHeight cause layout if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed null check Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/LocalDOMWindow.cpp ('k') | Source/web/tests/data/window_dimensions.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/PinchViewportTest.cpp
diff --git a/Source/web/tests/PinchViewportTest.cpp b/Source/web/tests/PinchViewportTest.cpp
index 686a14ba55612286909574e97d8f3f11808e385c..abd202f7210a8f6d2c16759c15b6692f535a7f4e 100644
--- a/Source/web/tests/PinchViewportTest.cpp
+++ b/Source/web/tests/PinchViewportTest.cpp
@@ -33,6 +33,8 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <string>
+
#define ASSERT_POINT_EQ(expected, actual) \
do { \
ASSERT_EQ((expected).x(), (actual).x()); \
@@ -1713,4 +1715,36 @@ TEST_F(PinchViewportTest, TestCoordinateTransforms)
EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport(FloatPoint(50, 62)));
}
+// Tests that the window dimensions are available before a full layout occurs.
+// More specifically, it checks that the innerWidth and innerHeight window
+// properties will trigger a layout which will cause an update to viewport
+// constraints and a refreshed initial scale. crbug.com/466718
+TEST_F(PinchViewportTest, WindowDimensionsOnLoad)
+{
+ initializeWithAndroidSettings();
+ registerMockedHttpURLLoad("window_dimensions.html");
+ webViewImpl()->resize(IntSize(800, 600));
+ navigateTo(m_baseURL + "window_dimensions.html");
+
+ Element* output = frame()->document()->getElementById("output");
+ ASSERT(output);
+ EXPECT_EQ(std::string("1600x1200"), std::string(output->innerHTML().ascii().data()));
+}
+
+// Similar to above but make sure the initial scale is updated with the content
+// width for a very wide page. That is, make that innerWidth/Height actually
+// trigger a layout of the content, and not just an update of the viepwort.
+// crbug.com/466718
+TEST_F(PinchViewportTest, WindowDimensionsOnLoadWideContent)
+{
+ initializeWithAndroidSettings();
+ registerMockedHttpURLLoad("window_dimensions_wide_div.html");
+ webViewImpl()->resize(IntSize(800, 600));
+ navigateTo(m_baseURL + "window_dimensions_wide_div.html");
+
+ Element* output = frame()->document()->getElementById("output");
+ ASSERT(output);
+ EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii().data()));
+}
+
} // namespace
« no previous file with comments | « Source/core/frame/LocalDOMWindow.cpp ('k') | Source/web/tests/data/window_dimensions.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698