Bug 1431601 - Move getViewportInfo function into viewport_helpers.js. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 15 Oct 2018 23:53:43 +0000
changeset 499849 4a79571c40a0ccb9cc0693fbd9ac46f22e2be84d
parent 499848 930561bbe55d1baaee2d2fde6fb4119e86fce70e
child 499850 d455d8d93e2c6a24761dc7392b965d24aa42b1b5
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1431601
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1431601 - Move getViewportInfo function into viewport_helpers.js. r=botond Depends on D8317 Differential Revision: https://phabricator.services.mozilla.com/D8318
dom/base/test/test_meta_viewport0.html
dom/base/test/test_meta_viewport1.html
dom/base/test/test_meta_viewport2.html
dom/base/test/test_meta_viewport3.html
dom/base/test/test_meta_viewport4.html
dom/base/test/test_meta_viewport5.html
dom/base/test/test_meta_viewport6.html
dom/base/test/test_meta_viewport7.html
dom/base/test/viewport_helpers.js
--- a/dom/base/test/test_meta_viewport0.html
+++ b/dom/base/test/test_meta_viewport0.html
@@ -46,34 +46,16 @@
           let info = getViewportInfo(800, 480);
           is(info.width,       980,     "width is still the default width");
           is(info.height,      588,     "height is still proportional to displayHeight");
 
           nextTest();
         });
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function nextTest() {
       if (tests.length)
         (tests.shift())();
       else
         SimpleTest.finish();
     }
     addEventListener("load", nextTest);
   </script>
--- a/dom/base/test/test_meta_viewport1.html
+++ b/dom/base/test/test_meta_viewport1.html
@@ -42,34 +42,16 @@
           is(info.defaultZoom, 1.5,  "initial zoom is 150%");
           is(info.width,       600,  "width equals displayWidth/1.5");
           is(info.height,      400,  "height equals displayHeight/1.5");
 
           nextTest();
         });
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function nextTest() {
       if (tests.length)
         (tests.shift())();
       else
         SimpleTest.finish();
     }
     addEventListener("load", nextTest);
   </script>
--- a/dom/base/test/test_meta_viewport2.html
+++ b/dom/base/test/test_meta_viewport2.html
@@ -42,34 +42,16 @@
           is(info.defaultZoom, 1.5,  "initial zoom is 150%");
           is(info.width,       600,  "width equals displayWidth/1.5");
           is(info.height,      400,  "height equals displayHeight/1.5");
 
           nextTest();
         });
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function nextTest() {
       if (tests.length)
         (tests.shift())();
       else
         SimpleTest.finish();
     }
     addEventListener("load", nextTest);
   </script>
--- a/dom/base/test/test_meta_viewport3.html
+++ b/dom/base/test/test_meta_viewport3.html
@@ -44,34 +44,16 @@
           is(info.defaultZoom, 2.5,   "initial zoom still fits the displayWidth");
           is(info.width,       320,   "width is still set explicitly");
           is(info.height,      40,   "height is still minimum height");
 
           nextTest();
         });
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function nextTest() {
       if (tests.length)
         (tests.shift())();
       else
         SimpleTest.finish();
     }
     addEventListener("load", nextTest);
   </script>
--- a/dom/base/test/test_meta_viewport4.html
+++ b/dom/base/test/test_meta_viewport4.html
@@ -43,34 +43,16 @@
           is(info.defaultZoom, 1.5,   "initial zoom is adjusted for device pixel ratio");
           is(info.width,       533,   "width fits the initial zoom");
           is(info.height,      320,   "height fits the initial zoom");
 
           nextTest();
         });
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function nextTest() {
       if (tests.length)
         (tests.shift())();
       else
         SimpleTest.finish();
     }
     addEventListener("load", nextTest);
   </script>
--- a/dom/base/test/test_meta_viewport5.html
+++ b/dom/base/test/test_meta_viewport5.html
@@ -19,34 +19,16 @@
 
     tests.push(function test1() {
       let info = getViewportInfo(800, 480);
       is(info.allowZoom, true, "user-scalable values are case-sensitive; 'NO' is not valid");
 
       nextTest();
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function nextTest() {
       if (tests.length)
         (tests.shift())();
       else
         SimpleTest.finish();
     }
     addEventListener("load", nextTest);
   </script>
--- a/dom/base/test/test_meta_viewport6.html
+++ b/dom/base/test/test_meta_viewport6.html
@@ -48,34 +48,16 @@
           is(info.maxZoom,     15,      "maximum scale defaults to the absolute maximum");
           is(info.width,       2000,    "width is still set explicitly");
           is(info.height,      1200,    "height is still proportional to displayHeight");
 
           nextTest();
         });
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function nextTest() {
       if (tests.length)
         (tests.shift())();
       else
         SimpleTest.finish();
     }
     addEventListener("load", nextTest);
   </script>
--- a/dom/base/test/test_meta_viewport7.html
+++ b/dom/base/test/test_meta_viewport7.html
@@ -73,34 +73,16 @@
           updateViewport("user-scalable=yes");
           let info = getViewportInfo(800, 480);
           is(info.allowZoom,   true,  "zooming is explicitly allowed");
 
           nextTest();
         });
     });
 
-    function getViewportInfo(aDisplayWidth, aDisplayHeight) {
-      let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
-          width = {}, height = {}, autoSize = {};
-
-      let cwu = SpecialPowers.getDOMWindowUtils(window);
-      cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
-                          minZoom, maxZoom, width, height, autoSize);
-      return {
-        defaultZoom: defaultZoom.value,
-        minZoom: minZoom.value,
-        maxZoom: maxZoom.value,
-        width: width.value,
-        height: height.value,
-        autoSize: autoSize.value,
-        allowZoom: allowZoom.value
-      };
-    }
-
     function updateViewport(content) {
       let meta = document.querySelector("meta[name=viewport]");
       meta.content = content;
     }
 
     function nextTest() {
       if (tests.length) {
         (tests.shift())();
--- a/dom/base/test/viewport_helpers.js
+++ b/dom/base/test/viewport_helpers.js
@@ -1,3 +1,21 @@
 function scaleRatio(scale) {
   return {"set": [["layout.css.devPixelsPerPx", "" + scale]]};
 }
+
+function getViewportInfo(aDisplayWidth, aDisplayHeight) {
+  let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
+      width = {}, height = {}, autoSize = {};
+
+  let cwu = SpecialPowers.getDOMWindowUtils(window);
+  cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
+                      minZoom, maxZoom, width, height, autoSize);
+  return {
+    defaultZoom: defaultZoom.value,
+    minZoom: minZoom.value,
+    maxZoom: maxZoom.value,
+    width: width.value,
+    height: height.value,
+    autoSize: autoSize.value,
+    allowZoom: allowZoom.value
+  };
+}