Bug 1819082 - Wait for l10n in editcacert dialog. r=Gijs

Use mozSubDialogReady (same as for content subdialogs) as an extra
waiting point.

Differential Revision: https://phabricator.services.mozilla.com/D171127
This commit is contained in:
Emilio Cobos Álvarez 2023-02-27 22:38:16 +00:00
parent a41029fc5c
commit c31776da57
3 changed files with 19 additions and 15 deletions

View file

@ -12,20 +12,15 @@ var gCertDB = Cc["@mozilla.org/security/x509certdb;1"].getService(
* *
* @type {nsIX509Cert} * @type {nsIX509Cert}
*/ */
var gCert; var gCert = window.arguments[0];
/** document.mozSubdialogReady = init();
* onload() handler.
*/
function onLoad() {
gCert = window.arguments[0];
document.addEventListener("dialogaccept", onDialogAccept); async function init() {
await new Promise(r => {
let certMsg = document.getElementById("certmsg"); document.addEventListener("DOMContentLoaded", r, { once: true });
document.l10n.setAttributes(certMsg, "edit-trust-ca", {
certName: gCert.commonName,
}); });
document.addEventListener("dialogaccept", onDialogAccept);
let sslCheckbox = document.getElementById("trustSSL"); let sslCheckbox = document.getElementById("trustSSL");
sslCheckbox.checked = gCertDB.isCertTrusted( sslCheckbox.checked = gCertDB.isCertTrusted(
@ -40,6 +35,14 @@ function onLoad() {
Ci.nsIX509Cert.CA_CERT, Ci.nsIX509Cert.CA_CERT,
Ci.nsIX509CertDB.TRUSTED_EMAIL Ci.nsIX509CertDB.TRUSTED_EMAIL
); );
let certMsg = document.getElementById("certmsg");
document.l10n.pauseObserving();
document.l10n.setAttributes(certMsg, "edit-trust-ca", {
certName: gCert.commonName,
});
document.l10n.resumeObserving();
await document.l10n.translateElements([certMsg]);
} }
/** /**

View file

@ -10,11 +10,9 @@
<window data-l10n-id="certmgr-edit-ca-cert2" <window data-l10n-id="certmgr-edit-ca-cert2"
data-l10n-attrs="style" data-l10n-attrs="style"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml">
onload="onLoad();">
<dialog id="editCaCert" <dialog id="editCaCert"
buttons="accept,cancel"> buttons="accept,cancel">
<linkset> <linkset>
<html:link rel="localization" href="security/certificates/certManager.ftl"/> <html:link rel="localization" href="security/certificates/certManager.ftl"/>
</linkset> </linkset>
@ -24,7 +22,7 @@
<description id="certmsg"/> <description id="certmsg"/>
<separator/> <separator/>
<description data-l10n-id="certmgr-edit-cert-edit-trust"></description> <description data-l10n-id="certmgr-edit-cert-edit-trust"/>
<vbox align="start"> <vbox align="start">
<checkbox data-l10n-id="certmgr-edit-cert-trust-ssl" <checkbox data-l10n-id="certmgr-edit-cert-trust-ssl"
id="trustSSL"/> id="trustSSL"/>

View file

@ -350,6 +350,9 @@
if (this._translationReady) { if (this._translationReady) {
await this._translationReady; await this._translationReady;
} }
if (document.mozSubDialogReady) {
await document.mozSubDialogReady;
}
let finalStep = () => { let finalStep = () => {
this._sizeToPreferredSize(); this._sizeToPreferredSize();