Bug 1253891 - "prefStrBundle.getFormattedString is not a function" exceptions in in-content/advanced.js. r=gijs

Guards were added to both async calls as it is likely that either of them could fire after the tab has been closed.

MozReview-Commit-ID: 9pKKNKXtxaP
This commit is contained in:
Jared Wein 2016-03-07 11:10:00 +01:00
Родитель 05225c81fc
Коммит 64075b6fc0
1 изменённых файлов: 10 добавлений и 0 удалений

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

@ -357,6 +357,11 @@ var gAdvancedPane = {
this.observer = {
onNetworkCacheDiskConsumption: function(consumption) {
var size = DownloadUtils.convertByteUnits(consumption);
// The XBL binding for the string bundle may have been destroyed if
// the page was closed before this callback was executed.
if (!prefStrBundle.getFormattedString) {
return;
}
actualSizeLabel.value = prefStrBundle.getFormattedString("actualDiskCacheSize", size);
},
@ -385,6 +390,11 @@ var gAdvancedPane = {
var actualSizeLabel = document.getElementById("actualAppCacheSize");
var sizeStrings = DownloadUtils.convertByteUnits(aConsumption);
var prefStrBundle = document.getElementById("bundlePreferences");
// The XBL binding for the string bundle may have been destroyed if
// the page was closed before this callback was executed.
if (!prefStrBundle.getFormattedString) {
return;
}
var sizeStr = prefStrBundle.getFormattedString("actualAppCacheSize", sizeStrings);
actualSizeLabel.value = sizeStr;
}