mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1485266 - Use stand-ins for native colors when RFP is enabled r=heycam
Differential Revision: https://phabricator.services.mozilla.com/D17755 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a38ff5b603
commit
bd2504a471
@ -2096,6 +2096,12 @@ bool nsContentUtils::ShouldResistFingerprinting(Document* aDoc) {
|
||||
return !isChrome && ShouldResistFingerprinting();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsContentUtils::UseStandinsForNativeColors() {
|
||||
return ShouldResistFingerprinting() ||
|
||||
StaticPrefs::ui_use_standins_for_native_colors();
|
||||
}
|
||||
|
||||
/* static */
|
||||
void nsContentUtils::CalcRoundedWindowSizeForResistingFingerprinting(
|
||||
int32_t aChromeWidth, int32_t aChromeHeight, int32_t aScreenWidth,
|
||||
|
@ -308,6 +308,9 @@ class nsContentUtils {
|
||||
static bool ShouldResistFingerprinting(nsIDocShell* aDocShell);
|
||||
static bool ShouldResistFingerprinting(Document* aDoc);
|
||||
|
||||
// Prevent system colors from being exposed to CSS or canvas.
|
||||
static bool UseStandinsForNativeColors();
|
||||
|
||||
// A helper function to calculate the rounded window size for fingerprinting
|
||||
// resistance. The rounded size is based on the chrome UI size and available
|
||||
// screen size. If the inputWidth/Height is greater than the available content
|
||||
|
@ -208,6 +208,7 @@ skip-if = android_version == '25' # bug 1336581
|
||||
[test_bug902651.html]
|
||||
[test_bug1215072.html]
|
||||
subsuite = gpu
|
||||
[test_bug1485266.html]
|
||||
[test_canvas.html]
|
||||
skip-if = (android_version == '18' && debug) || (webrender && toolkit == 'windows') # android 4.3 debug bug 1143317; bug 1464173 for webrender
|
||||
[test_canvas_focusring.html]
|
||||
|
135
dom/canvas/test/test_bug1485266.html
Normal file
135
dom/canvas/test/test_bug1485266.html
Normal file
@ -0,0 +1,135 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=14852266
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 14852266</title>
|
||||
<script type="application/javascript" 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=14852266">Mozilla Bug 14852266</a>
|
||||
<!-- CSS system colors -->
|
||||
<!--<table cellspacing=0 border=1>
|
||||
<caption>CSS system colors</caption>-->
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 14852266 **/
|
||||
|
||||
function beginTest() {
|
||||
var colorNames = [
|
||||
[ "ActiveBorder", 0xB4, 0xB4, 0xB4 ],
|
||||
[ "ActiveCaption", 0x99, 0xB4, 0xD1 ],
|
||||
[ "AppWorkspace", 0xAB, 0xAB, 0xAB ],
|
||||
[ "Background", 0x00, 0x00, 0x00 ],
|
||||
[ "ButtonFace", 0xF0, 0xF0, 0xF0 ],
|
||||
[ "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", 0xF0, 0xF0, 0xF0 ],
|
||||
[ "-moz-ButtonHoverText", 0x00, 0x00, 0x00 ],
|
||||
[ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ],
|
||||
[ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ],
|
||||
[ "-moz-Combobox", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-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-AlternatePrimaryHighlight", 0x3F, 0x3F, 0x3F ],
|
||||
[ "-moz-mac-SecondaryHighlight", 0xD4, 0xD4, 0xD4 ],
|
||||
[ "-moz-win-MediaText", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-win-CommunicationsText", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-html-CellHighlight", 0x33, 0x99, 0xFF ],
|
||||
[ "-moz-html-CellHighlightText", 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 colorTestDiv = document.createElement("div");
|
||||
document.body.appendChild(colorTestDiv); // ie
|
||||
|
||||
for (var i in colorNames) {
|
||||
(function(colorName, r, g, b) {
|
||||
// test value
|
||||
var ctest = "rgb(" + r + ", " + g + ", " + b + ")";
|
||||
|
||||
// computed value
|
||||
colorTestDiv.style.backgroundColor = "#FF00FE";
|
||||
try {
|
||||
colorTestDiv.style.backgroundColor = colorName;
|
||||
} catch (ex) {} // ie
|
||||
var c1;
|
||||
if (window.getComputedStyle) {
|
||||
c1 = getComputedStyle(colorTestDiv, null).backgroundColor;
|
||||
} else { // ie
|
||||
var range = document.body.createTextRange();
|
||||
range.moveToElementText(colorTestDiv);
|
||||
c1 = range.queryCommandValue("BackColor");
|
||||
c1 = "rgb(" + (c1 & 0xFF) + ", " + ((c1 >> 8) & 0xFF) + ", " + ((c1 >> 16) & 0xFF) + ")";
|
||||
}
|
||||
if (c1 != "rgb(255, 0, 254)") {
|
||||
is(c1, ctest, "Stand-in computed color: " + colorName + " is correct.");
|
||||
}
|
||||
|
||||
})(colorNames[i][0], colorNames[i][1], colorNames[i][2], colorNames[i][3]);
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
var prefs = [
|
||||
[ "privacy.resistFingerprinting", true ],
|
||||
[ "ui.use_standins_for_native_colors", false ],
|
||||
[ "ui.use_native_colors", true ],
|
||||
];
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({ "set" : prefs }, beginTest);
|
||||
|
||||
</script>
|
||||
<!-- </table> -->
|
||||
</body>
|
||||
</html>
|
@ -100,11 +100,6 @@ using namespace mozilla::layers;
|
||||
|
||||
uint8_t gNotifySubDocInvalidationData;
|
||||
|
||||
// This preference was first introduced in Bug 232227, in order to prevent
|
||||
// system colors from being exposed to CSS or canvas.
|
||||
constexpr char kUseStandinsForNativeColors[] =
|
||||
"ui.use_standins_for_native_colors";
|
||||
|
||||
/**
|
||||
* Layer UserData for ContainerLayers that want to be notified
|
||||
* of local invalidations of them and their descendant layers.
|
||||
@ -277,7 +272,6 @@ static const char* gExactCallbackPrefs[] = {
|
||||
"layout.css.devPixelsPerPx",
|
||||
"nglayout.debug.paint_flashing",
|
||||
"nglayout.debug.paint_flashing_chrome",
|
||||
kUseStandinsForNativeColors,
|
||||
"intl.accept_languages",
|
||||
nullptr,
|
||||
};
|
||||
@ -376,16 +370,10 @@ void nsPresContext::GetDocumentColorPreferences() {
|
||||
bool isChromeDocShell = false;
|
||||
static int32_t sDocumentColorsSetting;
|
||||
static bool sDocumentColorsSettingPrefCached = false;
|
||||
static bool sUseStandinsForNativeColors = false;
|
||||
if (!sDocumentColorsSettingPrefCached) {
|
||||
sDocumentColorsSettingPrefCached = true;
|
||||
Preferences::AddIntVarCache(&sDocumentColorsSetting,
|
||||
"browser.display.document_color_use", 0);
|
||||
|
||||
// The preference "ui.use_standins_for_native_colors" also affects
|
||||
// default foreground and background colors.
|
||||
Preferences::AddBoolVarCache(&sUseStandinsForNativeColors,
|
||||
kUseStandinsForNativeColors);
|
||||
}
|
||||
|
||||
dom::Document* doc = mDocument->GetDisplayDocument();
|
||||
@ -415,9 +403,9 @@ void nsPresContext::GetDocumentColorPreferences() {
|
||||
!Preferences::GetBool("browser.display.use_system_colors", false);
|
||||
}
|
||||
|
||||
if (sUseStandinsForNativeColors) {
|
||||
// Once the preference "ui.use_standins_for_native_colors" is enabled,
|
||||
// use fixed color values instead of prefered colors and system colors.
|
||||
if (nsContentUtils::UseStandinsForNativeColors()) {
|
||||
// Once the |nsContentUtils::UseStandinsForNativeColors()| is true,
|
||||
// use fixed color values instead of preferred colors and system colors.
|
||||
mDefaultColor = LookAndFeel::GetColorUsingStandins(
|
||||
LookAndFeel::eColorID_windowtext, NS_RGB(0x00, 0x00, 0x00));
|
||||
mBackgroundColor = LookAndFeel::GetColorUsingStandins(
|
||||
|
@ -1964,6 +1964,13 @@ VARCACHE_PREF(
|
||||
bool, true
|
||||
)
|
||||
|
||||
// Prevent system colors from being exposed to CSS or canvas.
|
||||
VARCACHE_PREF(
|
||||
"ui.use_standins_for_native_colors",
|
||||
ui_use_standins_for_native_colors,
|
||||
RelaxedAtomicBool, false
|
||||
)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// ChannelClassifier prefs
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -214,7 +214,6 @@ int32_t nsXPLookAndFeel::sCachedColorBits[COLOR_CACHE_SIZE] = {0};
|
||||
|
||||
bool nsXPLookAndFeel::sInitialized = false;
|
||||
bool nsXPLookAndFeel::sUseNativeColors = true;
|
||||
bool nsXPLookAndFeel::sUseStandinsForNativeColors = false;
|
||||
bool nsXPLookAndFeel::sFindbarModalHighlight = false;
|
||||
bool nsXPLookAndFeel::sIsInPrefersReducedMotionForTest = false;
|
||||
bool nsXPLookAndFeel::sPrefersReducedMotionForTest = false;
|
||||
@ -418,9 +417,6 @@ void nsXPLookAndFeel::Init() {
|
||||
|
||||
Preferences::AddBoolVarCache(&sUseNativeColors, "ui.use_native_colors",
|
||||
sUseNativeColors);
|
||||
Preferences::AddBoolVarCache(&sUseStandinsForNativeColors,
|
||||
"ui.use_standins_for_native_colors",
|
||||
sUseStandinsForNativeColors);
|
||||
Preferences::AddBoolVarCache(&sFindbarModalHighlight,
|
||||
"findbar.modalHighlight",
|
||||
sFindbarModalHighlight);
|
||||
@ -830,7 +826,8 @@ nsresult nsXPLookAndFeel::GetColorImpl(ColorID aID,
|
||||
#endif // DEBUG_SYSTEM_COLOR_USE
|
||||
|
||||
if (aUseStandinsForNativeColors &&
|
||||
(ColorIsNotCSSAccessible(aID) || !sUseStandinsForNativeColors)) {
|
||||
(ColorIsNotCSSAccessible(aID) ||
|
||||
!nsContentUtils::UseStandinsForNativeColors())) {
|
||||
aUseStandinsForNativeColors = false;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,6 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
|
||||
static int32_t sCachedColors[LookAndFeel::eColorID_LAST_COLOR];
|
||||
static int32_t sCachedColorBits[COLOR_CACHE_SIZE];
|
||||
static bool sUseNativeColors;
|
||||
static bool sUseStandinsForNativeColors;
|
||||
static bool sFindbarModalHighlight;
|
||||
|
||||
static nsXPLookAndFeel* sInstance;
|
||||
|
Loading…
Reference in New Issue
Block a user