Bug 1055279 - Open toolbox automatically for runtime apps and tabs. r=paul

This commit is contained in:
J. Ryan Stinnett 2014-09-12 10:31:43 -07:00
Родитель f45b0af958
Коммит 3d657a9f8f
5 изменённых файлов: 71 добавлений и 18 удалений

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

@ -132,10 +132,11 @@ let UI = {
break;
case "project":
this.updateTitle();
this.closeToolbox();
this.destroyToolbox();
this.updateCommands();
this.updateProjectButton();
this.openProject();
this.autoStartProject();
break;
case "project-is-not-running":
case "project-is-running":
@ -481,6 +482,26 @@ let UI = {
}, console.error);
},
autoStartProject: function() {
let project = AppManager.selectedProject;
if (!project) {
return;
}
if (!(project.type == "runtimeApp" ||
project.type == "mainProcess" ||
project.type == "tab")) {
return; // For something that is not an editable app, we're done.
}
Task.spawn(function() {
if (project.type == "runtimeApp") {
yield UI.busyUntil(AppManager.runRuntimeApp(), "running app");
}
yield UI.createToolbox();
});
},
/********** DECK **********/
setupDeck: function() {
@ -629,7 +650,7 @@ let UI = {
} catch(e) { console.error(e); }
},
closeToolbox: function() {
destroyToolbox: function() {
if (this.toolboxPromise) {
this.toolboxPromise.then(toolbox => {
toolbox.destroy();
@ -638,6 +659,13 @@ let UI = {
}
},
createToolbox: function() {
this.toolboxPromise = AppManager.getTarget().then((target) => {
return this.showToolbox(target);
}, console.error);
return this.busyUntil(this.toolboxPromise, "opening toolbox");
},
showToolbox: function(target) {
if (this.toolboxIframe) {
return;
@ -999,14 +1027,10 @@ let Cmds = {
toggleToolbox: function() {
if (UI.toolboxIframe) {
UI.closeToolbox();
UI.destroyToolbox();
return promise.resolve();
} else {
UI.toolboxPromise = AppManager.getTarget().then((target) => {
return UI.showToolbox(target);
}, console.error);
UI.busyUntil(UI.toolboxPromise, "opening toolbox");
return UI.toolboxPromise;
return UI.createToolbox();
}
},

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

@ -333,9 +333,6 @@ exports.AppManager = AppManager = {
this.tabStore.selectedTab = null;
if (this.selectedProject) {
if (this.selectedProject.type == "runtimeApp") {
this.runRuntimeApp();
}
if (this.selectedProject.type == "packaged" ||
this.selectedProject.type == "hosted") {
this.validateProject(this.selectedProject);

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

@ -58,6 +58,8 @@ TabStore.prototype = {
_resetStore: function() {
this.response = null;
this.tabs = [];
this._selectedTab = null;
this._selectedTabTargetPromise = null;
},
_onStatusChanged: function() {
@ -115,6 +117,7 @@ TabStore.prototype = {
// which is the selected project. This should be done as part of the
// project-agnostic work.
_selectedTab: null,
_selectedTabTargetPromise: null,
get selectedTab() {
return this._selectedTab;
},
@ -134,13 +137,18 @@ TabStore.prototype = {
return tab.actor === this._selectedTab.actor;
});
if (!alive) {
this._selectedTab = null;
this._selectedTabTargetPromise = null;
this.emit("closed");
}
},
getTargetForTab: function() {
if (this._selectedTabTargetPromise) {
return this._selectedTabTargetPromise;
}
let store = this;
return Task.spawn(function*() {
this._selectedTabTargetPromise = Task.spawn(function*() {
// If you connect to a tab, then detach from it, the root actor may have
// de-listed the actors that belong to the tab. This breaks the toolbox
// if you try to connect to the same tab again. To work around this
@ -152,6 +160,7 @@ TabStore.prototype = {
chrome: false
});
});
return this._selectedTabTargetPromise;
},
};

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

@ -101,6 +101,18 @@ function nextTick() {
return deferred.promise;
}
function waitForUpdate(win, update) {
let deferred = promise.defer();
win.AppManager.on("app-manager-update", function onUpdate(e, what) {
if (what !== update) {
return;
}
win.AppManager.off("app-manager-update", onUpdate);
deferred.resolve();
});
return deferred.promise;
}
function documentIsLoaded(doc) {
let deferred = promise.defer();
if (doc.readyState == "complete") {

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

@ -95,17 +95,28 @@
ok(!isPlayActive(), "play button is disabled 4");
ok(!isStopActive(), "stop button is disabled 4");
deferred = promise.defer();
win.AppManager.connection.once(
win.Connection.Events.CONNECTED,
() => deferred.resolve());
win.document.querySelectorAll(".runtime-panel-item-custom")[1].click();
yield deferred.promise;
yield waitForUpdate(win, "list-tabs-response");
is(Object.keys(DebuggerServer._connections).length, 1, "Locally connected");
ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
// Select main process
yield win.Cmds.showProjectPanel();
SimpleTest.executeSoon(() => {
win.document.querySelectorAll("#project-panel-runtimeapps .panel-item")[0].click();
});
yield waitForUpdate(win, "project");
// Toolbox opens automatically for main process / runtime apps
ok(win.UI.toolboxPromise, "Toolbox promise exists");
yield win.UI.toolboxPromise;
ok(win.UI.toolboxIframe, "Toolbox iframe exists");
yield win.Cmds.disconnectRuntime();
yield closeWebIDE(win);