Bug 1809488 - The TRR mode3 error page should not add exception when the resolver is not accessible r=acreskey,Gijs

If the error is caused by the TRR server not being accessible (maybe the
network is down) then adding an exception is unlikely to make the load.
Most likely the subsequent page load will also lead to an error page.

However, after connectivity is restored, the exception would remain.
Currently the ability to remove exceptions is lacking a UI.
In the future we might want to replace the exception button with a button
that would exclude the current tab from TRR instead - that way the
exception is not permanent when the failure is caused by a connection
failure to the TRR server.

Differential Revision: https://phabricator.services.mozilla.com/D168077
This commit is contained in:
Valentin Gosu 2023-02-03 14:48:11 +00:00
Родитель 55aaa5f649
Коммит 0e55a1ae49
4 изменённых файлов: 31 добавлений и 11 удалений

Просмотреть файл

@ -32,6 +32,7 @@ export class NetErrorChild extends RemotePageChild {
"RPMOpenPreferences",
"RPMGetTRRSkipReason",
"RPMGetTRRDomain",
"RPMIsSiteSpecificTRRError",
];
this.exportFunctions(exportableFunctions);
}
@ -175,11 +176,15 @@ export class NetErrorChild extends RemotePageChild {
return lazy.AppInfo.isFirefox;
}
RPMIsNativeFallbackFailure() {
_getTRRSkipReason() {
let channel = this.contentWindow?.docShell?.failedChannel?.QueryInterface(
Ci.nsIHttpChannelInternal
);
let value = channel?.trrSkipReason ?? Ci.nsITRRSkipReason.TRR_UNSET;
return channel?.trrSkipReason ?? Ci.nsITRRSkipReason.TRR_UNSET;
}
RPMIsNativeFallbackFailure() {
let skipReason = this._getTRRSkipReason();
const warningReasons = new Set([
Ci.nsITRRSkipReason.TRR_NOT_CONFIRMED,
@ -198,19 +203,27 @@ export class NetErrorChild extends RemotePageChild {
return (
Services.dns.currentTrrMode == Ci.nsIRequest.TRR_FIRST_MODE &&
warningReasons.has(value)
warningReasons.has(skipReason)
);
}
RPMGetTRRSkipReason() {
let channel = this.contentWindow?.docShell?.failedChannel?.QueryInterface(
Ci.nsIHttpChannelInternal
);
let value = channel?.trrSkipReason ?? Ci.nsITRRSkipReason.TRR_UNSET;
return Services.dns.getTRRSkipReasonName(value);
let skipReason = this._getTRRSkipReason();
return Services.dns.getTRRSkipReasonName(skipReason);
}
RPMGetTRRDomain() {
return Services.dns.trrDomain;
}
RPMIsSiteSpecificTRRError() {
let skipReason = this._getTRRSkipReason();
switch (skipReason) {
case Ci.nsITRRSkipReason.TRR_NXDOMAIN:
case Ci.nsITRRSkipReason.TRR_RCODE_FAIL:
case Ci.nsITRRSkipReason.TRR_NO_ANSWERS:
return true;
}
return false;
}
}

Просмотреть файл

@ -398,6 +398,7 @@ function initPage() {
});
shortDesc.textContent = "";
let skipReason = RPMGetTRRSkipReason();
// enable buttons
let trrExceptionButton = document.getElementById("trrExceptionButton");
@ -408,7 +409,13 @@ function initPage() {
retryThis(this);
});
});
trrExceptionButton.hidden = false;
if (RPMIsSiteSpecificTRRError()) {
// Only show the exclude button if the failure is specific to this
// domain. If the TRR server is inaccessible we don't want to allow
// the user to add an exception just for this domain.
trrExceptionButton.hidden = false;
}
let trrSettingsButton = document.getElementById("trrSettingsButton");
trrSettingsButton.addEventListener("click", () => {
RPMSendAsyncMessage("OpenTRRPreferences");
@ -423,8 +430,6 @@ function initPage() {
}
);
let skipReason = RPMGetTRRSkipReason();
let descriptionTag = "neterror-dns-not-found-trr-unknown-problem";
let args = { trrDomain: RPMGetTRRDomain() };
if (

Просмотреть файл

@ -107,6 +107,7 @@ export let RemotePageAccessManager = {
RPMIsNativeFallbackFailure: ["*"],
RPMGetTRRSkipReason: ["*"],
RPMGetTRRDomain: ["*"],
RPMIsSiteSpecificTRRError: ["*"],
RPMSendQuery: ["Browser:AddTRRExcludedDomain"],
},
"about:plugins": {

Просмотреть файл

@ -37,5 +37,6 @@ module.exports = {
RPMOpenPreferences: false,
RPMGetTRRSkipReason: false,
RPMGetTRRDomain: false,
RPMIsSiteSpecificTRRError: false,
},
};