summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/fonts/test/browser_fontinspector_all-fonts.js
blob: 7f2acfaebb66661e870f0e235ab4cd2646ee1acc (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

// Check that the font editor has a section for "All fonts" which shows all fonts
// used on the page.

const TEST_URI = URL_ROOT_SSL + "doc_browser_fontinspector.html";

add_task(async function () {
  const { view } = await openFontInspectorForURL(TEST_URI);
  const viewDoc = view.document;

  const allFontsAccordion = getFontsAccordion(viewDoc);
  ok(allFontsAccordion, "There's an accordion in the panel");
  is(
    allFontsAccordion.textContent,
    "All Fonts on Page",
    "It has the right title"
  );

  await expandAccordion(allFontsAccordion);
  const allFontsEls = getAllFontsEls(viewDoc);

  const FONTS = [
    {
      familyName: ["bar"],
      name: ["Ostrich Sans Medium"],
      remote: true,
      url: URL_ROOT_SSL + "ostrich-regular.ttf",
    },
    {
      familyName: ["bar"],
      name: ["Ostrich Sans Black"],
      remote: true,
      url: URL_ROOT_SSL + "ostrich-black.ttf",
    },
    {
      familyName: ["bar"],
      name: ["Ostrich Sans Black"],
      remote: true,
      url: URL_ROOT_SSL + "ostrich-black.ttf",
    },
    {
      familyName: ["barnormal"],
      name: ["Ostrich Sans Medium"],
      remote: true,
      url: URL_ROOT_SSL + "ostrich-regular.ttf",
    },
    {
      // On Linux, Arial does not exist. Liberation Sans is used instead.
      familyName: ["Arial", "Liberation Sans"],
      name: ["Arial", "Liberation Sans"],
      remote: false,
      url: "system",
    },
    {
      // On Linux, Times New Roman does not exist. Liberation Serif is used instead.
      familyName: ["Times New Roman", "Liberation Serif"],
      name: ["Times New Roman", "Liberation Serif"],
      remote: false,
      url: "system",
    },
  ];

  is(allFontsEls.length, FONTS.length, "All fonts used are listed");

  for (let i = 0; i < FONTS.length; i++) {
    const li = allFontsEls[i];
    const font = FONTS[i];

    ok(font.name.includes(getName(li)), "The DIV font has the right name");
    info(getName(li));
    ok(
      font.familyName.includes(getFamilyName(li)),
      `font has the right family name`
    );
    info(getFamilyName(li));
    is(isRemote(li), font.remote, `font remote value correct`);
    is(getURL(li), font.url, `font url correct`);
  }
});