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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
"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);
if (backgroundColorSetOnRoot()) {
let docEl = document.documentElement;
let rootCS = window.getComputedStyle(docEl);
Assert.equal(
rootCS.getPropertyValue("background-position"),
`${RIGHT_TOP}, ${RIGHT_TOP}`,
"root contains theme_frame and lwt-background-alignment properties"
);
Assert.equal(
toolboxCS.getPropertyValue("background-position"),
RIGHT_TOP,
toolbox.id + " contains lwt-background-alignment properties"
);
} else {
/**
* 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);
if (backgroundColorSetOnRoot()) {
let docEl = document.documentElement;
let rootCS = window.getComputedStyle(docEl);
Assert.equal(
rootCS.getPropertyValue("background-position"),
`${RIGHT_TOP}, ${LEFT_BOTTOM}, ${CENTER_CENTER}, ${RIGHT_TOP}`,
"root contains theme_frame and additional_backgrounds alignment properties"
);
Assert.equal(
toolboxCS.getPropertyValue("background-position"),
LEFT_BOTTOM + ", " + CENTER_CENTER + ", " + RIGHT_TOP,
toolbox.id + " contains additional_backgrounds alignment properties"
);
} else {
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();
});
|