Bug 1610741 - DoH Settings UI: Show error reason in Not Available label r=Gijs,kershaw,fluent-reviewers,necko-reviewers,settings-reviewers,flod

- The patch saves the confirmation channel's status and skipReason in the TRR Service
- The UI queries the status and displays the stringified version in the Not Available (reason) label
- Introduces doh-status-label CSS rule so the Learn-More link isn't off center

Differential Revision: https://phabricator.services.mozilla.com/D174110
This commit is contained in:
Valentin Gosu
2023-04-11 09:57:28 +00:00
parent 203d05ce00
commit e93296a122
10 changed files with 124 additions and 21 deletions

View File

@@ -608,8 +608,12 @@ var gPrivacyPane = {
let status = document.getElementById("dohStatus");
async function setStatus(localizedStringName) {
let statusString = await document.l10n.formatValue(localizedStringName);
async function setStatus(localizedStringName, options) {
let opts = options || {};
let statusString = await document.l10n.formatValue(
localizedStringName,
opts
);
document.l10n.setAttributes(status, "preferences-doh-status", {
status: statusString,
});
@@ -635,11 +639,23 @@ var gPrivacyPane = {
return "preferences-doh-status-disabled";
}
let errReason = "";
let confirmationStatus = Services.dns.lastConfirmationStatus;
if (confirmationStatus != Cr.NS_OK) {
errReason = ChromeUtils.getXPCOMErrorName(confirmationStatus);
} else {
errReason = Services.dns.getTRRSkipReasonName(
Services.dns.lastConfirmationSkipReason
);
}
let statusLabel = computeStatus();
// setStatus will format and set the statusLabel asynchronously.
setStatus(statusLabel);
setStatus(statusLabel, { reason: errReason });
dohResolver.hidden = statusLabel == "preferences-doh-status-disabled";
let statusLearnMore = document.getElementById("dohStatusLearnMore");
statusLearnMore.hidden = statusLabel != "preferences-doh-status-not-active";
// No need to set the resolver name since we're not going to show it.
if (statusLabel == "preferences-doh-status-disabled") {
return;