diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/test_bug232227.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/test_bug232227.html')
-rw-r--r-- | dom/canvas/test/test_bug232227.html | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/dom/canvas/test/test_bug232227.html b/dom/canvas/test/test_bug232227.html new file mode 100644 index 0000000000..97f31dd251 --- /dev/null +++ b/dom/canvas/test/test_bug232227.html @@ -0,0 +1,133 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=232227 +--> +<head> + <title>Test for Bug 232227</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=232227">Mozilla Bug 232227</a> +<script> + +/** Test for Bug 232227 **/ + +function runTest(testCanvasColors) { + var colorNames = [ + [ "ActiveBorder", 0xB4, 0xB4, 0xB4 ], + [ "ActiveCaption", 0x99, 0xB4, 0xD1 ], + [ "AppWorkspace", 0xAB, 0xAB, 0xAB ], + [ "Background", 0x00, 0x00, 0x00 ], + [ "ButtonFace", 0xe9, 0xe9, 0xed], + [ "ButtonHighlight", 0xFF, 0xFF, 0xFF ], + [ "ButtonShadow", 0xA0, 0xA0, 0xA0 ], + [ "ButtonText", 0x00, 0x00, 0x00 ], + [ "CaptionText", 0x00, 0x00, 0x00 ], + [ "GrayText", 0x6D, 0x6D, 0x6D ], + [ "Highlight", 0x33, 0x99, 0xFF ], + [ "HighlightText", 0xFF, 0xFF, 0xFF ], + [ "InactiveBorder", 0xF4, 0xF7, 0xFC ], + [ "InactiveCaption", 0xBF, 0xCD, 0xDB ], + [ "InactiveCaptionText", 0x43, 0x4E, 0x54 ], + [ "InfoBackground", 0xFF, 0xFF, 0xE1 ], + [ "InfoText", 0x00, 0x00, 0x00 ], + [ "Menu", 0xF0, 0xF0, 0xF0 ], + [ "MenuText", 0x00, 0x00, 0x00 ], + [ "Scrollbar", 0xC8, 0xC8, 0xC8 ], + [ "ThreeDDarkShadow", 0x69, 0x69, 0x69 ], + [ "ThreeDFace", 0xF0, 0xF0, 0xF0 ], + [ "ThreeDHighlight", 0xFF, 0xFF, 0xFF ], + [ "ThreeDLightShadow", 0xE3, 0xE3, 0xE3 ], + [ "ThreeDShadow", 0xA0, 0xA0, 0xA0 ], + [ "Window", 0xFF, 0xFF, 0xFF ], + [ "WindowFrame", 0x64, 0x64, 0x64 ], + [ "WindowText", 0x00, 0x00, 0x00 ], + [ "-moz-ButtonDefault", 0x69, 0x69, 0x69 ], + [ "-moz-ButtonHoverFace", 0xd0, 0xd0, 0xd7 ], + [ "-moz-ButtonHoverText", 0x00, 0x00, 0x00 ], + [ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ], + [ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ], + [ "-moz-Combobox", 0xe9, 0xe9, 0xed], + [ "-moz-ComboboxText", 0x00, 0x00, 0x00 ], + [ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ], + [ "-moz-DialogText", 0x00, 0x00, 0x00 ], + [ "-moz-DragTargetZone", 0xFF, 0xFF, 0xFF ], + [ "-moz-EvenTreeRow", 0xFF, 0xFF, 0xFF ], + [ "-moz-Field", 0xFF, 0xFF, 0xFF ], + [ "-moz-FieldText", 0x00, 0x00, 0x00 ], + [ "-moz-MenuHover", 0x33, 0x99, 0xFF ], + [ "-moz-MenuHoverText", 0x00, 0x00, 0x00 ], + [ "-moz-MenubarText", 0x00, 0x00, 0x00 ], + [ "-moz-MenubarHoverText", 0x00, 0x00, 0x00 ], + [ "-moz-NativeHyperlinkText", 0x00, 0x66, 0xCC ], + [ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ], + [ "-moz-mac-chrome-active", 0xB2, 0xB2, 0xB2 ], + [ "-moz-mac-chrome-inactive", 0xE1, 0xE1, 0xE1 ], + [ "-moz-mac-focusring", 0x60, 0x9D, 0xD7 ], + [ "-moz-mac-menuselect", 0x38, 0x75, 0xD7 ], + [ "-moz-mac-menushadow", 0xA3, 0xA3, 0xA3 ], + [ "-moz-mac-menutextdisable", 0x88, 0x88, 0x88 ], + [ "-moz-mac-menutextselect", 0xFF, 0xFF, 0xFF ], + [ "-moz-mac-DisabledToolbarText", 0x3F, 0x3F, 0x3F ], + [ "-moz-mac-SecondaryHighlight", 0xD4, 0xD4, 0xD4 ], + [ "-moz-win-MediaText", 0xFF, 0xFF, 0xFF ], + [ "-moz-win-CommunicationsText", 0xFF, 0xFF, 0xFF ], + [ "SelectedItem", 0x33, 0x99, 0xFF ], + [ "SelectedItemText", 0xFF, 0xFF, 0xFF ], + + // These five are configured via Tools -> Options -> Content -> Colors. + //"-moz-ActiveHyperlinkText", + //"-moz-HyperLinkText", + //"-moz-VisitedHyperlinkText", + //"-moz-default-background-color", + //"-moz-default-color", + ]; + + var colorTestCanvas = document.createElement("canvas"); + colorTestCanvas.width = colorTestCanvas.height = 1; + colorTestCanvas = colorTestCanvas.getContext("2d"); + + var colorTestDiv = document.createElement("div"); + document.body.appendChild(colorTestDiv); + + for (let [colorName, r, g, b] of colorNames) { + // test value + var ctest = "rgb(" + r + ", " + g + ", " + b + ")"; + + // computed value + colorTestDiv.style.backgroundColor = ""; + colorTestDiv.style.backgroundColor = colorName; + var c1 = getComputedStyle(colorTestDiv).backgroundColor; + is(c1, ctest, "Stand-in computed color: " + colorName + " is correct."); + + // canvas + if (testCanvasColors && colorTestCanvas) { + colorTestCanvas.fillStyle = colorName; + colorTestCanvas.fillRect(0, 0, 1, 1); + var c2 = colorTestCanvas.getImageData(0, 0, 1, 1).data; + c2 = "rgb(" + c2[0] + ", " + c2[1] + ", " + c2[2] + ")"; + is(c2, ctest, "Stand-in canvas color: " + colorName + " is correct."); + } + } +} + +(async function() { + SimpleTest.waitForExplicitFinish(); + await SpecialPowers.pushPrefEnv({ "set" : [ + [ "ui.use_standins_for_native_colors", true ], + ]}); + runTest(/* testCanvasColors = */ true); + await SpecialPowers.pushPrefEnv({ "set" : [ + [ "privacy.resistFingerprinting", true ], + [ "ui.use_standins_for_native_colors", false ], + ]}); + // With privacy.resistFingerprinting canvas data doesn't reflect the actual + // canvas, apparently. + runTest(/* testCanvasColors = */ false); + SimpleTest.finish(); +}()); +</script> +</body> +</html> |