Bug 1501106 - Various test cases checking current autoSize behavior. r=botond

Following four conditions are where nsIDocument::mAutoSize is true and
test cases for each condition. The conditions are the cases where we
currently set nsIDocument::mAutoSize true in nsIDocument:GetViewportInfo.

1) width=device-width
  test_meta_viewport_auto_size_by_device_width.html
2) no width && height=device-height
  test_meta_viewport_auto_size_by_device_height.html
3) no width && initial-scale=1
  test_meta_viewport_auto_size_by_fixed_height_and_initial_scale_1.html
  test_meta_viewport_auto_size_by_initial_scale_1.html
4) invalid width && (invalid height || no height)
  test_meta_viewport_auto_size_by_invalid_width.html

Below tests are cases that autoSize is disabled.
  test_meta_viewport_auto_size_by_fixed_width_and_initial_scale_1.html
  test_meta_viewport_auto_size_by_fixed_width_and_device_height.html
  test_meta_viewport_auto_size_by_initial_scale_0_5.html
  test_meta_viewport_auto_size_by_invalid_width_and_fixed_height.html

Depends on D9460

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2018-10-24 21:46:55 +00:00
parent cadab956a0
commit e47a1d0529
10 changed files with 240 additions and 0 deletions

View File

@ -692,6 +692,15 @@ skip-if = !e10s # Track Bug 1281415
[test_meta_viewport5.html] [test_meta_viewport5.html]
[test_meta_viewport6.html] [test_meta_viewport6.html]
[test_meta_viewport7.html] [test_meta_viewport7.html]
[test_meta_viewport_auto_size_by_device_height.html]
[test_meta_viewport_auto_size_by_device_width.html]
[test_meta_viewport_auto_size_by_fixed_height_and_initial_scale_1.html]
[test_meta_viewport_auto_size_by_fixed_width_and_device_height.html]
[test_meta_viewport_auto_size_by_fixed_width_and_initial_scale_1.html]
[test_meta_viewport_auto_size_by_initial_scale_0_5.html]
[test_meta_viewport_auto_size_by_initial_scale_1.html]
[test_meta_viewport_auto_size_by_invalid_width.html]
[test_meta_viewport_auto_size_by_invalid_width_and_fixed_height.html]
[test_meta_viewport_device_width.html] [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_0_5.html]
[test_meta_viewport_device_width_with_initial_scale_2.html] [test_meta_viewport_device_width_with_initial_scale_2.html]

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>device-height enables autoSize</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="height=device-height">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>height=device-height</p>
<script type="application/javascript">
"use strict";
add_task(async function device_height() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(info.autoSize, "device-height should enable autoSize");
});
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>device-width enables autoSize</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=device-width">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>width=device-width</p>
<script type="application/javascript">
"use strict";
add_task(async function device_width() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(info.autoSize, "device-width should enable autoSize");
});
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>initial-scale=1 with fixed height enable autoSize</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="height=400, initial-scale=1">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>height=400, initial-scale=1</p>
<script type="application/javascript">
"use strict";
add_task(async function fixed_height_and_initial_scale_1() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(info.autoSize,
"initial-scale=1 with fixed height should enable autoSize");
});
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Fixed width and device-height disables autoSize</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=400,height=device-height">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>width=400, height=device-height</p>
<script type="application/javascript">
"use strict";
add_task(async function fixed_width_and_device_height() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(!info.autoSize,
"Fixed width should disable autoSize even if height is device-height");
});
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>initial-scale=1 with fixed width disables autoSize</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=400, initial-scale=1">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>width=400, initial-scale=1</p>
<script type="application/javascript">
"use strict";
add_task(async function fixed_width_and_initial_scale_1() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(!info.autoSize,
"initial-scale=1 with fixed width should disable autoSize");
});
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>initial-scale!=1 without width disables autoSize</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="initial-scale=0.5">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>initial-scale!=1</p>
<script type="application/javascript">
"use strict";
add_task(async function initial_scale_0_5() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(!info.autoSize,
"initial-scale!=1 without width should disable autoSize");
});
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>initial-scale=1 without width enables autoSize</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="initial-scale=1">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>initial-scale=1</p>
<script type="application/javascript">
"use strict";
add_task(async function initial_scale_1() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(info.autoSize,
"initial-scale=1 without width should enable autoSize");
});
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>invalid width enables autoSize</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=-1">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>width=-1</p>
<script type="application/javascript">
"use strict";
add_task(async function invalid_width() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(info.autoSize, "invalid width should enable autoSize");
});
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>invalid width but with fixed height disables autoSize</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=-1,height=200">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>width=-1,height=200</p>
<script type="application/javascript">
"use strict";
add_task(async function invalid_width_and_fixed_height() {
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
let info = getViewportInfo(800, 480);
ok(!info.autoSize,
"invalid width but with valid height should disable autoSize");
});
</script>
</body>
</html>