test_bug232227.html (4535B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=232227 5 --> 6 <head> 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"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=232227">Mozilla Bug 232227</a> 13 <script> 14 15 /** Test for Bug 232227 */ 16 17 function runTest(testCanvasColors) { 18 var colorNames = [ 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", 0x8f, 0x8f, 0x9d], // deprecated, same as ButtonBorder (bug 1803933) 34 [ "ThreeDFace", 0xE9, 0xE9, 0xED ], // deprecated, same as ButtonFace (bug 1874064) 35 [ "ThreeDHighlight", 0x8f, 0x8f, 0x9d], // deprecated, same as ButtonBorder (bug 1803933) 36 [ "ThreeDLightShadow", 0x8f, 0x8f, 0x9d], 37 [ "ThreeDShadow", 0x8f, 0x8f, 0x9d], // deprecated, same as ButtonBorder (bug 1803933) 38 [ "Window", 0xFF, 0xFF, 0xFF ], 39 [ "WindowFrame", 0x8f, 0x8f, 0x9d], // deprecated, same as ButtonBorder (bug 1803933) 40 [ "WindowText", 0x00, 0x00, 0x00 ], 41 [ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ], 42 [ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ], 43 [ "-moz-Combobox", 0xE9, 0xE9, 0xED ], 44 [ "-moz-ComboboxText", 0x00, 0x00, 0x00 ], 45 [ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ], 46 [ "-moz-DialogText", 0x00, 0x00, 0x00 ], 47 [ "-moz-Field", 0xFF, 0xFF, 0xFF ], 48 [ "-moz-FieldText", 0x00, 0x00, 0x00 ], 49 [ "-moz-MenuHover", 0x33, 0x99, 0xFF ], 50 [ "-moz-MenuHoverText", 0x00, 0x00, 0x00 ], 51 [ "-moz-MenubarHoverText", 0x00, 0x00, 0x00 ], 52 [ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ], 53 [ "SelectedItem", 0x33, 0x99, 0xFF ], 54 [ "SelectedItemText", 0xFF, 0xFF, 0xFF ], 55 56 // These five are configured via Tools -> Options -> Content -> Colors. 57 //"-moz-ActiveHyperlinkText", 58 //"-moz-HyperLinkText", 59 //"-moz-VisitedHyperlinkText", 60 //"-moz-default-background-color", 61 //"-moz-default-color", 62 ]; 63 64 var colorTestCanvas = document.createElement("canvas"); 65 colorTestCanvas.width = colorTestCanvas.height = 1; 66 colorTestCanvas = colorTestCanvas.getContext("2d"); 67 68 var colorTestDiv = document.createElement("div"); 69 document.body.appendChild(colorTestDiv); 70 71 for (let [colorName, r, g, b] of colorNames) { 72 // test value 73 var ctest = "rgb(" + r + ", " + g + ", " + b + ")"; 74 75 // computed value 76 colorTestDiv.style.backgroundColor = ""; 77 colorTestDiv.style.backgroundColor = colorName; 78 var c1 = getComputedStyle(colorTestDiv).backgroundColor; 79 is(c1, ctest, "Stand-in computed color: " + colorName + " is correct."); 80 81 // canvas 82 if (testCanvasColors && colorTestCanvas) { 83 colorTestCanvas.fillStyle = colorName; 84 colorTestCanvas.fillRect(0, 0, 1, 1); 85 var c2 = colorTestCanvas.getImageData(0, 0, 1, 1).data; 86 c2 = "rgb(" + c2[0] + ", " + c2[1] + ", " + c2[2] + ")"; 87 is(c2, ctest, "Stand-in canvas color: " + colorName + " is correct."); 88 } 89 } 90 } 91 92 (async function() { 93 SimpleTest.waitForExplicitFinish(); 94 await SpecialPowers.pushPrefEnv({ "set" : [ 95 [ "ui.use_standins_for_native_colors", true ], 96 ]}); 97 runTest(/* testCanvasColors = */ true); 98 await SpecialPowers.pushPrefEnv({ "set" : [ 99 [ "privacy.resistFingerprinting", true ], 100 [ "ui.use_standins_for_native_colors", false ], 101 ]}); 102 // With privacy.resistFingerprinting canvas data doesn't reflect the actual 103 // canvas, apparently. 104 runTest(/* testCanvasColors = */ false); 105 SimpleTest.finish(); 106 }()); 107 </script> 108 </body> 109 </html>