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
120
121
122
123
124
125
126
|
/* exported ACCENT_COLOR, BACKGROUND, ENCODED_IMAGE_DATA, FRAME_COLOR, TAB_TEXT_COLOR,
TEXT_COLOR, TAB_BACKGROUND_TEXT_COLOR, imageBufferFromDataURI, hexToCSS, hexToRGB, testBorderColor,
waitForTransition, loadTestSubscript, backgroundColorSetOnRoot, assertPersistentListeners */
"use strict";
const { ClientEnvironmentBase } = ChromeUtils.importESModule(
"resource://gre/modules/components-utils/ClientEnvironment.sys.mjs"
);
const BACKGROUND =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0" +
"DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
const ENCODED_IMAGE_DATA =
"iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0h" +
"STQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAdhwAAHYcBj+XxZQAAB5dJREFUSMd" +
"91vmTlEcZB/Bvd7/vO+/ce83O3gfLDUsC4VgIghBUEo2GM9GCFTaQBEISA1qIEVNQ4aggJDGIgAGTlFUKKcqKQpVHaQyny7FrCMiywp4ze+/Mzs67M/P" +
"O+3a3v5jdWo32H/B86vv0U083weecV3+0C8lkEh6PhzS3tuLkieMSAKo3fW9Mb1eoUt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FgRyCznDpfGFwdKqirF2tu5SdIeGrkiP+KS5yb7dHtIKsnI++kP9rS8RQvjmxxe" +
"jePxD2HHwwP9FdCllurGhUbx14CAbiMc4Y2qVJqwLbo0qfpdLSilILB4Xg0mT6h7vnSWzZn9RoaynobWF3K6rk1NmzMWZ83/+37+V4a1cVg5JACYF45b" +
"FGVVWOFS2V1HUCjOdBqW0Q9fYb7N9/tcSptnldjpott8rFEXBO+f+NKrWMHL9Wu1nSUAIAaUUa59aAyE43E4X3bD8W6K5K6x1h1snRaMDJDuQf7+vrzf" +
"eG+mgfrcLHh3C79bx6wttGEqERiH/AjPohWMouv2ZAAAAAElFTkSuQmCC";
const ACCENT_COLOR = "#a14040";
const TEXT_COLOR = "#fac96e";
// For testing aliases of the colors above:
const FRAME_COLOR = [71, 105, 91];
const TAB_BACKGROUND_TEXT_COLOR = [207, 221, 192, 0.9];
function hexToRGB(hex) {
if (!hex) {
return null;
}
hex = parseInt(hex.indexOf("#") > -1 ? hex.substring(1) : hex, 16);
return [hex >> 16, (hex & 0x00ff00) >> 8, hex & 0x0000ff];
}
function rgbToCSS(rgb) {
return `rgb(${rgb.join(", ")})`;
}
function hexToCSS(hex) {
if (!hex) {
return null;
}
return rgbToCSS(hexToRGB(hex));
}
function imageBufferFromDataURI(encodedImageData) {
let decodedImageData = atob(encodedImageData);
return Uint8Array.from(decodedImageData, byte => byte.charCodeAt(0)).buffer;
}
function waitForTransition(element, propertyName) {
return BrowserTestUtils.waitForEvent(
element,
"transitionend",
false,
event => {
return event.target == element && event.propertyName == propertyName;
}
);
}
function testBorderColor(element, expected) {
let computedStyle = window.getComputedStyle(element);
Assert.equal(
computedStyle.borderLeftColor,
hexToCSS(expected),
"Element left border color should be set."
);
Assert.equal(
computedStyle.borderRightColor,
hexToCSS(expected),
"Element right border color should be set."
);
Assert.equal(
computedStyle.borderTopColor,
hexToCSS(expected),
"Element top border color should be set."
);
Assert.equal(
computedStyle.borderBottomColor,
hexToCSS(expected),
"Element bottom border color should be set."
);
}
function loadTestSubscript(filePath) {
Services.scriptloader.loadSubScript(new URL(filePath, gTestPath).href, this);
}
/**
* Windows 7 and 8 set the window's background-color on :root instead of
* #navigator-toolbox to avoid bug 1695280. When that bug is fixed, this
* function and the assertions it gates can be removed.
*
* @returns {boolean} True if the window's background-color is set on :root
* rather than #navigator-toolbox.
*/
function backgroundColorSetOnRoot() {
const os = ClientEnvironmentBase.os;
if (!os.isWindows) {
return false;
}
return os.windowsVersion < 10;
}
// Persistent Listener test functionality
const { assertPersistentListeners } = ExtensionTestUtils.testAssertions;
|