Bug 1242567 - Cleanup OptionsPanel.open by using Task.async. r=bgrins

This commit is contained in:
Alexandre Poirot 2016-01-26 03:23:47 -08:00
parent 29b34d38a9
commit df7141649a

View File

@ -8,6 +8,7 @@ const {Cu, Cc, Ci} = require("chrome");
const Services = require("Services");
const promise = require("promise");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", "resource://devtools/client/framework/gDevTools.jsm");
exports.OptionsPanel = OptionsPanel;
@ -94,32 +95,21 @@ OptionsPanel.prototype = {
return this.toolbox.target;
},
open: function() {
let targetPromise;
open: Task.async(function*() {
// For local debugging we need to make the target remote.
if (!this.target.isRemote) {
targetPromise = this.target.makeRemote();
} else {
targetPromise = promise.resolve(this.target);
yield this.target.makeRemote();
}
return targetPromise.then(() => {
this.setupToolsList();
this.setupToolbarButtonsList();
this.setupThemeList();
this.updateDefaultTheme();
}).then(() => {
return this.populatePreferences();
}).then(() => {
this.isReady = true;
this.emit("ready");
return this;
}).then(null, function onError(aReason) {
Cu.reportError("OptionsPanel open failed. " +
aReason.error + ": " + aReason.message);
});
},
this.setupToolsList();
this.setupToolbarButtonsList();
this.setupThemeList();
this.updateDefaultTheme();
yield this.populatePreferences();
this.isReady = true;
this.emit("ready");
return this;
}),
_addListeners: function() {
gDevTools.on("pref-changed", this._prefChanged);