Bug 1148893 - Replace .then handlers with yields to catch 'Unknown sheet source' rejections in Style Editor onShow task. r=ejpbruel

This commit is contained in:
Sami Jaktholm 2015-03-28 10:15:29 +02:00
Родитель 63f9ca53ff
Коммит cd332ecd32
1 изменённых файлов: 22 добавлений и 23 удалений

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

@ -550,30 +550,29 @@ StyleEditorUI.prototype = {
this.emit("editor-selected", editor);
// Is there any CSS coverage markup to include?
csscoverage.getUsage(this._target).then(usage => {
if (usage == null) {
return;
let usage = yield csscoverage.getUsage(this._target);
if (usage == null) {
return;
}
let href = csscoverage.sheetToUrl(editor.styleSheet);
let data = yield usage.createEditorReport(href)
editor.removeAllUnusedRegions();
if (data.reports.length > 0) {
// Only apply if this file isn't compressed. We detect a
// compressed file if there are more rules than lines.
let text = editor.sourceEditor.getText();
let lineCount = text.split("\n").length;
let ruleCount = editor.styleSheet.ruleCount;
if (lineCount >= ruleCount) {
editor.addUnusedRegions(data.reports);
}
let href = csscoverage.sheetToUrl(editor.styleSheet);
usage.createEditorReport(href).then(data => {
editor.removeAllUnusedRegions();
if (data.reports.length > 0) {
// Only apply if this file isn't compressed. We detect a
// compressed file if there are more rules than lines.
let text = editor.sourceEditor.getText();
let lineCount = text.split("\n").length;
let ruleCount = editor.styleSheet.ruleCount;
if (lineCount >= ruleCount) {
editor.addUnusedRegions(data.reports);
}
else {
this.emit("error", { key: "error-compressed", level: "info" });
}
}
}, Cu.reportError);
}, Cu.reportError);
else {
this.emit("error", { key: "error-compressed", level: "info" });
}
}
}.bind(this)).then(null, Cu.reportError);
}.bind(this)
});