summaryrefslogtreecommitdiffstats
path: root/dom/base/test/meta_viewport/viewport_helpers.js
blob: d4d346b5d0a66ef681a92a71bf0645f4f5e557fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function scaleRatio(scale) {
  return {
    set: [
      ["layout.css.devPixelsPerPx", "" + scale],
      ["dom.meta-viewport.enabled", true],
    ],
  };
}

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 fuzzeq(a, b, msg) {
  ok(Math.abs(a - b) < 1e-6, msg);
}