summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/browser/browser_ext_themes_additional_backgrounds_alignment.js
blob: b02e552ecbeb941f297e74a99cd17e5253ecaf10 (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
83
84
85
86
87
88
"use strict";

// Case 1 - When there is a theme_frame image and additional_backgrounds_alignment is not specified.
// So background-position should default to "right top"
add_task(async function test_default_additional_backgrounds_alignment() {
  const RIGHT_TOP = "100% 0%";

  let extension = ExtensionTestUtils.loadExtension({
    manifest: {
      theme: {
        images: {
          theme_frame: "image1.png",
          additional_backgrounds: ["image1.png", "image1.png"],
        },
        colors: {
          frame: ACCENT_COLOR,
          tab_background_text: TEXT_COLOR,
        },
      },
    },
    files: {
      "image1.png": BACKGROUND,
    },
  });

  await extension.startup();

  let toolbox = document.querySelector("#navigator-toolbox");
  let toolboxCS = window.getComputedStyle(toolbox);
  /**
   * We expect duplicate background-position values because we apply `right top`
   * once for theme_frame, and again as the default value of
   * --lwt-background-alignment.
   */
  Assert.equal(
    toolboxCS.getPropertyValue("background-position"),
    `${RIGHT_TOP}, ${RIGHT_TOP}`,
    toolbox.id +
      " contains theme_frame and default lwt-background-alignment properties"
  );

  await extension.unload();
});

// Case 2 - When there is a theme_frame image and additional_backgrounds_alignment is specified.
add_task(async function test_additional_backgrounds_alignment() {
  const LEFT_BOTTOM = "0% 100%";
  const CENTER_CENTER = "50% 50%";
  const RIGHT_TOP = "100% 0%";

  let extension = ExtensionTestUtils.loadExtension({
    manifest: {
      theme: {
        images: {
          theme_frame: "image1.png",
          additional_backgrounds: ["image1.png", "image1.png", "image1.png"],
        },
        colors: {
          frame: ACCENT_COLOR,
          tab_background_text: TEXT_COLOR,
        },
        properties: {
          additional_backgrounds_alignment: [
            "left bottom",
            "center center",
            "right top",
          ],
        },
      },
    },
    files: {
      "image1.png": BACKGROUND,
    },
  });

  await extension.startup();

  let toolbox = document.querySelector("#navigator-toolbox");
  let toolboxCS = window.getComputedStyle(toolbox);
  Assert.equal(
    toolboxCS.getPropertyValue("background-position"),
    RIGHT_TOP + ", " + LEFT_BOTTOM + ", " + CENTER_CENTER + ", " + RIGHT_TOP,
    toolbox.id +
      " contains theme_frame and additional_backgrounds alignment properties"
  );

  await extension.unload();
});