Bug 1501665 Part 11: Add a new test of meta viewport with zero display width. r=botond

This test ensures that when meta viewport width is fixed, and a viewport
is requested with zero width, the viewport is assigned a height equal to
the scaled display height.

Differential Revision: https://phabricator.services.mozilla.com/D22436

--HG--
extra : source : 5bdf0ad9dc6639dd86499fded67183f77407a8ee
This commit is contained in:
Brad Werth 2019-03-18 15:00:53 +00:00
parent 9a86c02a44
commit b2a1c08a45
2 changed files with 31 additions and 0 deletions

View File

@ -711,6 +711,7 @@ skip-if = !e10s # Track Bug 1281415
[test_meta_viewport_device_width.html]
[test_meta_viewport_device_width_with_initial_scale_0_5.html]
[test_meta_viewport_device_width_with_initial_scale_2.html]
[test_meta_viewport_fixed_width_and_zero_display_width.html]
[test_meta_viewport_initial_scale_0_5.html]
[test_meta_viewport_initial_scale_2.html]
[test_meta_viewport_maximum_scale_0.html]

View File

@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Fixed meta viewport width, zero display width</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta name="viewport" content="width=100">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>Fixed meta viewport width, zero display width</p>
<script type="application/javascript">
"use strict";
add_task(async function valid_width() {
// We choose a 2.5 scaleRatio here to make clear that the later check
// of the viewport height is getting a scaled value.
await SpecialPowers.pushPrefEnv(scaleRatio(2.5));
// We request a zero-width viewport because that triggers a special
// codepath that sets the viewport height to the scaled display height.
let info = getViewportInfo(0, 500);
is(info.width, 100, "width should be 100");
is(info.height, 200, "height should be 200, since 500 / 2.5 = 200");
});
</script>
</body>
</html>