mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1830623, part 3 - Update DNT UI to match GPC UI - r=anti-tracking-reviewers,mconley,timhuang,emilio
Differential Revision: https://phabricator.services.mozilla.com/D184585
This commit is contained in:
parent
17d859818d
commit
ef0c1ff6bd
@ -352,18 +352,28 @@
|
||||
id="globalPrivacyControlLearnMoreLink"
|
||||
support-page="global-privacy-control" />
|
||||
</hbox>
|
||||
<label>
|
||||
<label class="tail-with-learn-more" data-l10n-id="do-not-track-description" id="doNotTrackDesc"></label>
|
||||
<html:a is="moz-support-link"
|
||||
class="learnMore"
|
||||
data-l10n-id="do-not-track-learn-more"
|
||||
support-page="how-do-i-turn-do-not-track-feature"
|
||||
/>
|
||||
</label>
|
||||
<radiogroup id="doNotTrackRadioGroup" aria-labelledby="doNotTrackDesc" preference="privacy.donottrackheader.enabled">
|
||||
<radio value="true" data-l10n-id="do-not-track-option-always"/>
|
||||
<radio value="false" data-l10n-id="do-not-track-option-default-content-blocking-known"/>
|
||||
</radiogroup>
|
||||
<vbox id="legacyDoNotTrackBox">
|
||||
<label>
|
||||
<label class="tail-with-learn-more" data-l10n-id="do-not-track-description" id="doNotTrackDesc"></label>
|
||||
<html:a is="moz-support-link"
|
||||
class="learnMore"
|
||||
support-page="how-do-i-turn-do-not-track-feature"
|
||||
/>
|
||||
</label>
|
||||
<radiogroup id="doNotTrackRadioGroup" aria-labelledby="doNotTrackDesc" preference="privacy.donottrackheader.enabled">
|
||||
<radio value="true" data-l10n-id="do-not-track-option-always"/>
|
||||
<radio value="false" data-l10n-id="do-not-track-option-default-content-blocking-known"/>
|
||||
</radiogroup>
|
||||
</vbox>
|
||||
<hbox id="doNotTrackBox" flex="1" align="center">
|
||||
<checkbox id="doNotTrackCheckbox"
|
||||
class="tail-with-learn-more"
|
||||
preference="privacy.donottrackheader.enabled"
|
||||
data-l10n-id="do-not-track-description2" />
|
||||
<html:a is="moz-support-link"
|
||||
id="doNotTrackLearnMoreLink"
|
||||
support-page="how-do-i-turn-do-not-track-feature" />
|
||||
</hbox>
|
||||
</vbox>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
@ -2986,6 +2986,8 @@ var gPrivacyPane = {
|
||||
);
|
||||
document.getElementById("globalPrivacyControlBox").hidden =
|
||||
!gpcEnabledPrefValue;
|
||||
document.getElementById("doNotTrackBox").hidden = !gpcEnabledPrefValue;
|
||||
document.getElementById("legacyDoNotTrackBox").hidden = gpcEnabledPrefValue;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -98,6 +98,7 @@ skip-if = true
|
||||
[browser_privacy_cookieBannerHandling.js]
|
||||
[browser_privacy_dnsoverhttps.js]
|
||||
[browser_privacy_firefoxSuggest.js]
|
||||
[browser_privacy_gpc.js]
|
||||
[browser_privacy_passwordGenerationAndAutofill.js]
|
||||
[browser_privacy_quickactions.js]
|
||||
[browser_privacy_relayIntegration.js]
|
||||
|
182
browser/components/preferences/tests/browser_privacy_gpc.js
Normal file
182
browser/components/preferences/tests/browser_privacy_gpc.js
Normal file
@ -0,0 +1,182 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// This file tests the Privacy pane's Cookie Banner Handling UI.
|
||||
|
||||
"use strict";
|
||||
|
||||
const FEATURE_PREF = "privacy.globalprivacycontrol.functionality.enabled";
|
||||
const MODE_PREF = "privacy.globalprivacycontrol.enabled";
|
||||
const DNT_PREF = "privacy.donottrackheader.enabled";
|
||||
|
||||
const SECTION_ID = "nonTechnicalPrivacyBox";
|
||||
const GPC_ID = "globalPrivacyControlBox";
|
||||
const GPC_CHECKBOX_ID = "globalPrivacyControlCheckbox";
|
||||
const OLD_DNT_ID = "legacyDoNotTrackBox";
|
||||
const NEW_DNT_ID = "doNotTrackBox";
|
||||
const DNT_CHECKBOX_ID = "doNotTrackCheckbox";
|
||||
|
||||
// Test the section is hidden on page load if the feature pref is disabled.
|
||||
// Also make sure we keep the old DNT interface.
|
||||
add_task(async function test_section_hidden_when_feature_flag_disabled() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[FEATURE_PREF, false],
|
||||
[MODE_PREF, false],
|
||||
],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:preferences#privacy" },
|
||||
async function (browser) {
|
||||
let gpc = browser.contentDocument.getElementById(GPC_ID);
|
||||
is_element_hidden(gpc, "#globalPrivacyControlBox is hidden");
|
||||
let new_dnt = browser.contentDocument.getElementById(NEW_DNT_ID);
|
||||
is_element_hidden(new_dnt, "#doNotTrackBox is hidden");
|
||||
let old_dnt = browser.contentDocument.getElementById(OLD_DNT_ID);
|
||||
is_element_visible(old_dnt, "#doNotTrackBox is shown");
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
// Test the section is shown on page load if the feature pref is enabled.
|
||||
// Also make sure we show the new DNT interface.
|
||||
add_task(async function test_section_shown_when_feature_flag_enabled() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[FEATURE_PREF, true],
|
||||
[MODE_PREF, false],
|
||||
],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:preferences#privacy" },
|
||||
async function (browser) {
|
||||
let gpc = browser.contentDocument.getElementById(GPC_ID);
|
||||
is_element_visible(gpc, "#globalPrivacyControlBox is shown");
|
||||
let new_dnt = browser.contentDocument.getElementById(NEW_DNT_ID);
|
||||
is_element_visible(new_dnt, "#doNotTrackBox is shown");
|
||||
let old_dnt = browser.contentDocument.getElementById(OLD_DNT_ID);
|
||||
is_element_hidden(old_dnt, "#doNotTrackBox is hidden");
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
// Test the checkbox is unchecked in DISABLED mode.
|
||||
add_task(async function test_checkbox_unchecked_disabled_mode() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[FEATURE_PREF, true],
|
||||
[MODE_PREF, false],
|
||||
],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:preferences#privacy" },
|
||||
async function (browser) {
|
||||
let checkbox = browser.contentDocument.getElementById(GPC_CHECKBOX_ID);
|
||||
ok(!checkbox.checked, "checkbox is not checked in DISABLED mode");
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
// Test that toggling the checkbox toggles the mode pref value as expected
|
||||
add_task(async function test_checkbox_modifies_prefs() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[FEATURE_PREF, true],
|
||||
[MODE_PREF, false],
|
||||
],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:preferences#privacy" },
|
||||
async function (browser) {
|
||||
let gpc_checkbox =
|
||||
browser.contentDocument.getElementById(GPC_CHECKBOX_ID);
|
||||
let dnt_checkbox =
|
||||
browser.contentDocument.getElementById(DNT_CHECKBOX_ID);
|
||||
let section = browser.contentDocument.getElementById(SECTION_ID);
|
||||
|
||||
section.scrollIntoView();
|
||||
|
||||
Assert.ok(
|
||||
!gpc_checkbox.checked && !dnt_checkbox.checked,
|
||||
"initially, the checkbox should be unchecked"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"#" + GPC_CHECKBOX_ID,
|
||||
{},
|
||||
browser
|
||||
);
|
||||
Assert.ok(
|
||||
gpc_checkbox.checked && !dnt_checkbox.checked,
|
||||
"gpc checkbox should be checked"
|
||||
);
|
||||
Assert.equal(
|
||||
true,
|
||||
Services.prefs.getBoolPref(MODE_PREF),
|
||||
"GPC should be on after checking the checkbox"
|
||||
);
|
||||
Assert.equal(
|
||||
false,
|
||||
Services.prefs.getBoolPref(DNT_PREF),
|
||||
"DNT should still be disabled after checking the checkbox"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"#" + DNT_CHECKBOX_ID,
|
||||
{},
|
||||
browser
|
||||
);
|
||||
Assert.ok(
|
||||
gpc_checkbox.checked && dnt_checkbox.checked,
|
||||
"both checkboxes are enabled"
|
||||
);
|
||||
Assert.equal(
|
||||
true,
|
||||
Services.prefs.getBoolPref(MODE_PREF),
|
||||
"GPC should still be on after checking the DNT checkbox"
|
||||
);
|
||||
Assert.equal(
|
||||
true,
|
||||
Services.prefs.getBoolPref(DNT_PREF),
|
||||
"DNT should still be enabled after checking the checkbox"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"#" + DNT_CHECKBOX_ID,
|
||||
{},
|
||||
browser
|
||||
);
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"#" + GPC_CHECKBOX_ID,
|
||||
{},
|
||||
browser
|
||||
);
|
||||
Assert.ok(
|
||||
!gpc_checkbox.checked && !dnt_checkbox.checked,
|
||||
"both checkboxes are disabled"
|
||||
);
|
||||
Assert.equal(
|
||||
false,
|
||||
Services.prefs.getBoolPref(MODE_PREF),
|
||||
"GPC should be unchecked"
|
||||
);
|
||||
Assert.equal(
|
||||
false,
|
||||
Services.prefs.getBoolPref(DNT_PREF),
|
||||
"DNT should be unchecked"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
@ -19,7 +19,6 @@ export var Preferences = {
|
||||
["panePrivacy", clearRecentHistoryDialog],
|
||||
["panePrivacy", certManager],
|
||||
["panePrivacy", deviceManager],
|
||||
["panePrivacy", DNTDialog],
|
||||
["paneSync"],
|
||||
];
|
||||
|
||||
@ -125,23 +124,6 @@ async function cacheGroup(aBrowser) {
|
||||
);
|
||||
}
|
||||
|
||||
async function DNTDialog(aBrowser) {
|
||||
return aBrowser.ownerGlobal.SpecialPowers.spawn(
|
||||
aBrowser,
|
||||
[],
|
||||
async function () {
|
||||
const button = content.document.getElementById("doNotTrackSettings");
|
||||
if (!button) {
|
||||
return {
|
||||
todo: "The dialog may have exited before we could click the button",
|
||||
};
|
||||
}
|
||||
button.click();
|
||||
return undefined;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function connectionDialog(aBrowser) {
|
||||
await aBrowser.ownerGlobal.SpecialPowers.spawn(
|
||||
aBrowser,
|
||||
|
@ -8,6 +8,7 @@ var supportedProps = [
|
||||
"appCodeName",
|
||||
"appName",
|
||||
"appVersion",
|
||||
{ name: "globalPrivacyControl", isNightly: true, isAndroid: false },
|
||||
"platform",
|
||||
"product",
|
||||
"userAgent",
|
||||
@ -43,7 +44,8 @@ function startTest(channelData) {
|
||||
if (
|
||||
prop.nightly === !channelData.isNightly ||
|
||||
prop.release === !channelData.isRelease ||
|
||||
prop.isSecureContext === !isSecureContext
|
||||
prop.isSecureContext === !isSecureContext ||
|
||||
prop.isAndroid === !channelData.isAndroid
|
||||
) {
|
||||
interfaceMap[prop.name] = false;
|
||||
continue;
|
||||
|
@ -60,5 +60,6 @@ var { AppConstants } = SpecialPowers.ChromeUtils.importESModule(
|
||||
);
|
||||
var isNightly = AppConstants.NIGHTLY_BUILD;
|
||||
var isRelease = AppConstants.RELEASE_OR_BETA;
|
||||
var isAndroid = AppConstants.platform == "android";
|
||||
|
||||
worker.postMessage({ isNightly, isRelease });
|
||||
worker.postMessage({ isNightly, isRelease, isAndroid });
|
||||
|
Loading…
Reference in New Issue
Block a user