Bug 1501106 - Various test cases checking current autoSize behavior. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 24 Oct 2018 21:46:55 +0000
changeset 491227 e46f20ef7d4c30d84f3ad8feccd2e33d60e0c989
parent 491226 09f5387e2002f4efa33043895decc4c05dcf5d18
child 491228 40b1b00e610a2db492b645184336bc2097c0cd28
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbotond
bugs1501106
milestone65.0a1
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
dom/base/test/mochitest.ini
dom/base/test/test_meta_viewport_auto_size_by_device_height.html
dom/base/test/test_meta_viewport_auto_size_by_device_width.html
dom/base/test/test_meta_viewport_auto_size_by_fixed_height_and_initial_scale_1.html
dom/base/test/test_meta_viewport_auto_size_by_fixed_width_and_device_height.html
dom/base/test/test_meta_viewport_auto_size_by_fixed_width_and_initial_scale_1.html
dom/base/test/test_meta_viewport_auto_size_by_initial_scale_0_5.html
dom/base/test/test_meta_viewport_auto_size_by_initial_scale_1.html
dom/base/test/test_meta_viewport_auto_size_by_invalid_width.html
dom/base/test/test_meta_viewport_auto_size_by_invalid_width_and_fixed_height.html
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -687,16 +687,25 @@ skip-if = !e10s # Track Bug 1281415
 [test_meta_viewport0.html]
 [test_meta_viewport1.html]
 [test_meta_viewport2.html]
 [test_meta_viewport3.html]
 [test_meta_viewport4.html]
 [test_meta_viewport5.html]
 [test_meta_viewport6.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_with_initial_scale_0_5.html]
 [test_meta_viewport_device_width_with_initial_scale_2.html]
 [test_meta_viewport_initial_scale_0_5.html]
 [test_meta_viewport_initial_scale_2.html]
 [test_meta_viewport_maximum_scale_0.html]
 [test_meta_viewport_maximum_scale_0_5.html]
 [test_meta_viewport_maximum_scale_2.html]
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_device_height.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_device_width.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_fixed_height_and_initial_scale_1.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_fixed_width_and_device_height.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_fixed_width_and_initial_scale_1.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_initial_scale_0_5.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_initial_scale_1.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_invalid_width.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_meta_viewport_auto_size_by_invalid_width_and_fixed_height.html
@@ -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>