| Index: content/renderer/render_view_browsertest.cc
|
| diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
|
| index fea6eff95b95035de4e30d384a51c6f69b0ffedb..feb9beee864668f9d69e35ff592fda750dc4bbc0 100644
|
| --- a/content/renderer/render_view_browsertest.cc
|
| +++ b/content/renderer/render_view_browsertest.cc
|
| @@ -501,27 +501,47 @@ class RenderViewImplScaleFactorTest : public RenderViewImplBlinkSettingsTest {
|
| ASSERT_EQ(dsf, view()->device_scale_factor_);
|
| }
|
|
|
| - void TestEmulatedSizeDprDsf(int width, int height, float dpr,
|
| + void TestEmulatedSizeDprDsf(int width,
|
| + int height,
|
| + int visual_viewport_width,
|
| + int visual_viewport_height,
|
| + float dpr,
|
| float compositor_dsf) {
|
| - static base::string16 get_width =
|
| + static base::string16 get_width = base::ASCIIToUTF16(
|
| + "Number(document.getElementById('layoutViewportDiv').clientWidth)");
|
| + static base::string16 get_height = base::ASCIIToUTF16(
|
| + "Number(document.getElementById('layoutViewportDiv').clientHeight)");
|
| + static base::string16 get_visual_width =
|
| base::ASCIIToUTF16("Number(window.innerWidth)");
|
| - static base::string16 get_height =
|
| + static base::string16 get_visual_height =
|
| base::ASCIIToUTF16("Number(window.innerHeight)");
|
| static base::string16 get_dpr =
|
| base::ASCIIToUTF16("Number(window.devicePixelRatio * 10)");
|
|
|
| int emulated_width, emulated_height;
|
| + int emulated_visual_width, emulated_visual_height;
|
| int emulated_dpr;
|
| blink::WebDeviceEmulationParams params;
|
| params.viewSize.width = width;
|
| params.viewSize.height = height;
|
| + params.visualViewportSize.width = visual_viewport_width;
|
| + params.visualViewportSize.height = visual_viewport_height;
|
| params.deviceScaleFactor = dpr;
|
| view()->OnEnableDeviceEmulation(params);
|
| + ProcessPendingMessages();
|
| EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_width, &emulated_width));
|
| EXPECT_EQ(width, emulated_width);
|
| EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height,
|
| &emulated_height));
|
| EXPECT_EQ(height, emulated_height);
|
| + EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_visual_width,
|
| + &emulated_visual_width));
|
| + EXPECT_EQ(visual_viewport_width > 0 ? visual_viewport_width : width,
|
| + emulated_visual_width);
|
| + EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_visual_height,
|
| + &emulated_visual_height));
|
| + EXPECT_EQ(visual_viewport_height > 0 ? visual_viewport_height : height,
|
| + emulated_visual_height);
|
| EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_dpr, &emulated_dpr));
|
| EXPECT_EQ(static_cast<int>(dpr * 10), emulated_dpr);
|
| EXPECT_EQ(compositor_dsf,
|
| @@ -2229,22 +2249,33 @@ TEST_F(RenderViewImplScaleFactorTest, ScreenMetricsEmulationWithOriginalDSF1) {
|
| DoSetUp();
|
| SetDeviceScaleFactor(1.f);
|
|
|
| - LoadHTML("<body style='min-height:1000px;'></body>");
|
| + LoadHTML(
|
| + "<body style='min-height:1000px; overflow:hidden; margin:0px;'>"
|
| + "<div id='layoutViewportDiv' style='width:100%; height:100%;'></div>"
|
| + "</body>");
|
| {
|
| SCOPED_TRACE("327x415 1dpr");
|
| - TestEmulatedSizeDprDsf(327, 415, 1.f, 1.f);
|
| + TestEmulatedSizeDprDsf(327, 415, 0, 0, 1.f, 1.f);
|
| }
|
| {
|
| SCOPED_TRACE("327x415 1.5dpr");
|
| - TestEmulatedSizeDprDsf(327, 415, 1.5f, 1.f);
|
| + TestEmulatedSizeDprDsf(327, 415, 0, 0, 1.5f, 1.f);
|
| }
|
| {
|
| SCOPED_TRACE("1005x1102 2dpr");
|
| - TestEmulatedSizeDprDsf(1005, 1102, 2.f, 1.f);
|
| + TestEmulatedSizeDprDsf(1005, 1102, 0, 0, 2.f, 1.f);
|
| }
|
| {
|
| SCOPED_TRACE("1005x1102 3dpr");
|
| - TestEmulatedSizeDprDsf(1005, 1102, 3.f, 1.f);
|
| + TestEmulatedSizeDprDsf(1005, 1102, 0, 0, 3.f, 1.f);
|
| + }
|
| + {
|
| + SCOPED_TRACE("654x830 visual 327x415 1dpr");
|
| + TestEmulatedSizeDprDsf(654, 830, 327, 415, 1.f, 1.f);
|
| + }
|
| + {
|
| + SCOPED_TRACE("654x830 visual 327x415 2dpr");
|
| + TestEmulatedSizeDprDsf(654, 830, 327, 415, 2.f, 1.f);
|
| }
|
|
|
| view()->OnDisableDeviceEmulation();
|
| @@ -2260,22 +2291,33 @@ TEST_F(RenderViewImplScaleFactorTest, ScreenMetricsEmulationWithOriginalDSF2) {
|
| float compositor_dsf =
|
| IsUseZoomForDSFEnabled() ? 1.f : 2.f;
|
|
|
| - LoadHTML("<body style='min-height:1000px;'></body>");
|
| + LoadHTML(
|
| + "<body style='min-height:1000px; overflow:hidden; margin:0px;'>"
|
| + "<div id='layoutViewportDiv' style='width:100%; height:100%;'></div>"
|
| + "</body>");
|
| {
|
| SCOPED_TRACE("327x415 1dpr");
|
| - TestEmulatedSizeDprDsf(327, 415, 1.f, compositor_dsf);
|
| + TestEmulatedSizeDprDsf(327, 415, 0, 0, 1.f, compositor_dsf);
|
| }
|
| {
|
| SCOPED_TRACE("327x415 1.5dpr");
|
| - TestEmulatedSizeDprDsf(327, 415, 1.5f, compositor_dsf);
|
| + TestEmulatedSizeDprDsf(327, 415, 0, 0, 1.5f, compositor_dsf);
|
| }
|
| {
|
| SCOPED_TRACE("1005x1102 2dpr");
|
| - TestEmulatedSizeDprDsf(1005, 1102, 2.f, compositor_dsf);
|
| + TestEmulatedSizeDprDsf(1005, 1102, 0, 0, 2.f, compositor_dsf);
|
| }
|
| {
|
| SCOPED_TRACE("1005x1102 3dpr");
|
| - TestEmulatedSizeDprDsf(1005, 1102, 3.f, compositor_dsf);
|
| + TestEmulatedSizeDprDsf(1005, 1102, 0, 0, 3.f, compositor_dsf);
|
| + }
|
| + {
|
| + SCOPED_TRACE("654x830 visual 327x415 1dpr");
|
| + TestEmulatedSizeDprDsf(654, 830, 327, 415, 1.f, compositor_dsf);
|
| + }
|
| + {
|
| + SCOPED_TRACE("654x830 visual 327x415 2dpr");
|
| + TestEmulatedSizeDprDsf(654, 830, 327, 415, 2.f, compositor_dsf);
|
| }
|
|
|
| view()->OnDisableDeviceEmulation();
|
|
|