Bug 1453765 - Switch Fluent from warning to throwing errors when in debug/testing mode. r=Gijs

MozReview-Commit-ID: 1y7FTCPWRxb

--HG--
extra : rebase_source : fb4d20e383efd64bbdfce5ca1d78aca40716b57a
This commit is contained in:
Zibi Braniecki 2018-05-22 20:49:29 -07:00
parent 966bced714
commit 1c5fcde883
5 changed files with 19 additions and 10 deletions

View File

@ -228,7 +228,7 @@
<button id="clearSiteDataButton"
class="accessory-button"
icon="clear"
search-l10n-ids="clear-site-data-cookies, clear-site-data-cache"
search-l10n-ids="clear-site-data-cookies-empty.label, clear-site-data-cache-empty.label"
data-l10n-id="sitedata-clear"/>
</hbox>
<hbox>

View File

@ -38,7 +38,7 @@ let gSiteDataSettings = {
let label = document.createElement("label");
label.setAttribute("crop", "end");
if (l10n) {
if (l10n.raw) {
if (l10n.hasOwnProperty("raw")) {
box.setAttribute("tooltiptext", l10n.raw);
label.setAttribute("value", l10n.raw);
} else {

View File

@ -611,7 +611,10 @@ class DOMLocalization extends Localization {
if (this.pendingElements.size > 0) {
if (this.pendingrAF === null) {
this.pendingrAF = this.windowElement.requestAnimationFrame(() => {
this.translateElements(Array.from(this.pendingElements));
// We need to filter for elements that lost their l10n-id while
// waiting for the animation frame.
this.translateElements(Array.from(this.pendingElements)
.filter(elem => elem.hasAttribute("data-l10n-id")));
this.pendingElements.clear();
this.pendingrAF = null;
});
@ -685,7 +688,10 @@ class DOMLocalization extends Localization {
}
this.resumeObserving();
})
.catch(() => this.resumeObserving());
.catch(e => {
this.resumeObserving();
throw e;
});
}
return this.translateElements(this.getTranslatables(frag));
}

View File

@ -148,9 +148,12 @@ class Localization {
break;
}
if (AppConstants.NIGHTLY_BUILD) {
if (AppConstants.NIGHTLY_BUILD || Cu.isInAutomation) {
const locale = ctx.locales[0];
const ids = Array.from(missingIds).join(", ");
if (Cu.isInAutomation) {
throw new Error(`Missing translations in ${locale}: ${ids}`);
}
console.warn(`Missing translations in ${locale}: ${ids}`);
}
}

View File

@ -27,11 +27,11 @@
mockGenerateMessages
);
await domLoc.translateFragment(document.body);
// we just care that it doesn't throw here.
ok(1);
await domLoc.translateFragment(document.body).then(() => {
ok(false, "Expected translateFragment to throw on missing l10n-id");
}, () => {
ok(true, "Expected translateFragment to throw on missing l10n-id");
});
SimpleTest.finish();
});
</script>