summaryrefslogtreecommitdiffstats
path: root/dom/html/test/browser_ImageDocument_svg_zoom.js
blob: f0df2282a3319f551d996aae6683281cfb649509 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const URL = `data:image/svg+xml,<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="green"/></svg>`;

function test_once() {
  return BrowserTestUtils.withNewTab(URL, async browser => {
    return await SpecialPowers.spawn(browser, [], async function () {
      const rect = content.document.documentElement.getBoundingClientRect();
      info(
        `${rect.width}x${rect.height}, ${content.innerWidth}x${content.innerHeight}`
      );
      is(
        Math.round(rect.height),
        content.innerHeight,
        "Should fill the viewport and not overflow"
      );
    });
  });
}

add_task(async function test_with_no_text_zoom() {
  await test_once();
});

add_task(async function test_with_text_zoom() {
  let dpi = window.devicePixelRatio;

  await SpecialPowers.pushPrefEnv({ set: [["ui.textScaleFactor", 200]] });
  Assert.greater(
    window.devicePixelRatio,
    dpi,
    "DPI should change as a result of the pref flip"
  );

  return test_once();
});