4 https://bugzilla.mozilla.org/show_bug.cgi?id=232227
7 <title>Test for Bug
232227</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=232227">Mozilla Bug
232227</a>
15 /** Test for Bug 232227 **/
17 function runTest(testCanvasColors
) {
19 [ "AppWorkspace", 0xFF, 0xFF, 0xFF ], // deprecated, same as Canvas/Window (bug 1803930)
20 [ "Background", 0xFF, 0xFF, 0xFF ], // deprecated, same as Canvas/Window (bug 1803930)
21 [ "ButtonFace", 0xE9, 0xE9, 0xED ],
22 [ "ButtonHighlight", 0xE9, 0xE9, 0xED ], // deprecated, same as ButtonFace (bug 1803932)
23 [ "ButtonShadow", 0xE9, 0xE9, 0xED ], // deprecated, same as ButtonFace (bug 1803932)
24 [ "ButtonText", 0x00, 0x00, 0x00 ],
25 [ "GrayText", 0x6D, 0x6D, 0x6D ],
26 [ "Highlight", 0x33, 0x99, 0xFF ],
27 [ "HighlightText", 0xFF, 0xFF, 0xFF ],
28 [ "InfoBackground", 0xFF, 0xFF, 0xFF ], // deprecated, same as Canvas/Window (bug 1874065)
29 [ "InfoText", 0x00, 0x00, 0x00 ], // deprecated, same as CanvasText/WindowText (bug 1803931)
30 [ "Menu", 0xFF, 0xFF, 0xFF ], // deprecated, same as Canvas/Window (bug 1803930)
31 [ "MenuText", 0x00, 0x00, 0x00 ], // deprecated, same as CanvasText/WindowText (bug 1873951)
32 [ "Scrollbar", 0xFF, 0xFF, 0xFF ], // deprecated, same as Canvas/Window (bug 1803930)
33 [ "ThreeDDarkShadow", 0xE3, 0xE3, 0xE3 ], // deprecated, same as ButtonBorder (bug 1803933)
34 [ "ThreeDFace", 0xE9, 0xE9, 0xED ], // deprecated, same as ButtonFace (bug 1874064)
35 [ "ThreeDHighlight", 0xE3, 0xE3, 0xE3 ], // deprecated, same as ButtonBorder (bug 1803933)
36 [ "ThreeDLightShadow", 0xE3, 0xE3, 0xE3 ],
37 [ "ThreeDShadow", 0xE3, 0xE3, 0xE3 ], // deprecated, same as ButtonBorder (bug 1803933)
38 [ "Window", 0xFF, 0xFF, 0xFF ],
39 [ "WindowFrame", 0xE3, 0xE3, 0xE3 ], // deprecated, same as ButtonBorder (bug 1803933)
40 [ "WindowText", 0x00, 0x00, 0x00 ],
41 [ "-moz-ButtonHoverFace", 0xD0, 0xD0, 0xD7 ],
42 [ "-moz-ButtonHoverText", 0x00, 0x00, 0x00 ],
43 [ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ],
44 [ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ],
45 [ "-moz-Combobox", 0xE9, 0xE9, 0xED ],
46 [ "-moz-ComboboxText", 0x00, 0x00, 0x00 ],
47 [ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ],
48 [ "-moz-DialogText", 0x00, 0x00, 0x00 ],
49 [ "-moz-EvenTreeRow", 0xFF, 0xFF, 0xFF ],
50 [ "-moz-Field", 0xFF, 0xFF, 0xFF ],
51 [ "-moz-FieldText", 0x00, 0x00, 0x00 ],
52 [ "-moz-MenuHover", 0x33, 0x99, 0xFF ],
53 [ "-moz-MenuHoverText", 0x00, 0x00, 0x00 ],
54 [ "-moz-MenubarHoverText", 0x00, 0x00, 0x00 ],
55 [ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ],
56 [ "SelectedItem", 0x33, 0x99, 0xFF ],
57 [ "SelectedItemText", 0xFF, 0xFF, 0xFF ],
59 // These five are configured via Tools -> Options -> Content -> Colors.
60 //"-moz-ActiveHyperlinkText",
61 //"-moz-HyperLinkText",
62 //"-moz-VisitedHyperlinkText",
63 //"-moz-default-background-color",
64 //"-moz-default-color",
67 var colorTestCanvas
= document
.createElement("canvas");
68 colorTestCanvas
.width
= colorTestCanvas
.height
= 1;
69 colorTestCanvas
= colorTestCanvas
.getContext("2d");
71 var colorTestDiv
= document
.createElement("div");
72 document
.body
.appendChild(colorTestDiv
);
74 for (let [colorName
, r
, g
, b
] of colorNames
) {
76 var ctest
= "rgb(" + r
+ ", " + g
+ ", " + b
+ ")";
79 colorTestDiv
.style
.backgroundColor
= "";
80 colorTestDiv
.style
.backgroundColor
= colorName
;
81 var c1
= getComputedStyle(colorTestDiv
).backgroundColor
;
82 is(c1
, ctest
, "Stand-in computed color: " + colorName
+ " is correct.");
85 if (testCanvasColors
&& colorTestCanvas
) {
86 colorTestCanvas
.fillStyle
= colorName
;
87 colorTestCanvas
.fillRect(0, 0, 1, 1);
88 var c2
= colorTestCanvas
.getImageData(0, 0, 1, 1).data
;
89 c2
= "rgb(" + c2
[0] + ", " + c2
[1] + ", " + c2
[2] + ")";
90 is(c2
, ctest
, "Stand-in canvas color: " + colorName
+ " is correct.");
96 SimpleTest
.waitForExplicitFinish();
97 await SpecialPowers
.pushPrefEnv({ "set" : [
98 [ "ui.use_standins_for_native_colors", true ],
100 runTest(/* testCanvasColors = */ true);
101 await SpecialPowers
.pushPrefEnv({ "set" : [
102 [ "privacy.resistFingerprinting", true ],
103 [ "ui.use_standins_for_native_colors", false ],
105 // With privacy.resistFingerprinting canvas data doesn't reflect the actual
106 // canvas, apparently.
107 runTest(/* testCanvasColors = */ false);