Index: content/renderer/render_frame_impl_browsertest.cc |
diff --git a/content/renderer/render_frame_impl_browsertest.cc b/content/renderer/render_frame_impl_browsertest.cc |
index 999a9b39c19c51c026e9aba30a9ca4c36729a5bc..0e5bed484010c748a767dd6fa80624e67c256087 100644 |
--- a/content/renderer/render_frame_impl_browsertest.cc |
+++ b/content/renderer/render_frame_impl_browsertest.cc |
@@ -18,12 +18,14 @@ |
#include "content/renderer/render_frame_impl.h" |
#include "content/renderer/render_view_impl.h" |
#include "content/test/fake_compositor_dependencies.h" |
+#include "content/test/test_render_frame.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h" |
#include "third_party/WebKit/public/platform/WebString.h" |
#include "third_party/WebKit/public/platform/WebURLRequest.h" |
#include "third_party/WebKit/public/web/WebHistoryItem.h" |
#include "third_party/WebKit/public/web/WebLocalFrame.h" |
+#include "third_party/WebKit/public/web/WebView.h" |
using blink::WebString; |
@@ -343,4 +345,32 @@ TEST_F(RenderFrameImplTest, SaveImageFromDataURL) { |
EXPECT_FALSE(msg4); |
} |
+TEST_F(RenderFrameImplTest, ZoomLimit) { |
+ const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
+ const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
+ |
+ // Verifies navigation to a URL with preset zoom level indeed sets the level. |
+ // Regression test for http://crbug.com/139559, where the level was not |
+ // properly set when it is out of the default zoom limits of WebView. |
+ CommonNavigationParams common_params; |
+ common_params.url = GURL("data:text/html,min_zoomlimit_test"); |
+ GetMainRenderFrame()->OnGotZoomLevel(common_params.url, kMinZoomLevel); |
+ TestRenderFrame* frame = static_cast<TestRenderFrame*>(GetMainRenderFrame()); |
+ frame->Navigate(common_params, StartNavigationParams(), |
+ RequestNavigationParams()); |
+ |
+ ProcessPendingMessages(); |
+ EXPECT_DOUBLE_EQ(kMinZoomLevel, view_->GetWebView()->zoomLevel()); |
+ |
+ // It should work even when the zoom limit is temporarily changed in the page. |
+ view_->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), |
+ ZoomFactorToZoomLevel(1.0)); |
+ common_params.url = GURL("data:text/html,max_zoomlimit_test"); |
+ GetMainRenderFrame()->OnGotZoomLevel(common_params.url, kMaxZoomLevel); |
+ frame->Navigate(common_params, StartNavigationParams(), |
+ RequestNavigationParams()); |
+ ProcessPendingMessages(); |
+ EXPECT_DOUBLE_EQ(kMaxZoomLevel, view_->GetWebView()->zoomLevel()); |
+} |
+ |
} // namespace |