Bug 1093883 - Disable app install for runtimes that don't allow it. r=jryans

This commit is contained in:
Paul Rouget 2014-11-09 23:26:00 -05:00
parent 50a4da3f23
commit 0bfa566de8
4 changed files with 45 additions and 16 deletions

View File

@ -285,7 +285,14 @@ let UI = {
this.cancelBusyTimeout();
this.unbusy();
}, (e) => {
let message = operationDescription + (e ? (": " + e) : "");
let message;
if (e.error && e.message) {
// Some errors come from fronts that are not based on protocol.js.
// Errors are not translated to strings.
message = operationDescription + " (" + e.error + "): " + e.message;
} else {
message = operationDescription + (e ? (": " + e) : "");
}
this.cancelBusyTimeout();
let operationCanceled = e && e.canceled;
if (!operationCanceled) {
@ -817,7 +824,8 @@ let UI = {
playCmd.setAttribute("disabled", "true");
stopCmd.setAttribute("disabled", "true");
} else {
if (AppManager.selectedProject.errorsCount == 0) {
if (AppManager.selectedProject.errorsCount == 0 &&
AppManager.runtimeCanHandleApps()) {
playCmd.removeAttribute("disabled");
} else {
playCmd.setAttribute("disabled", "true");

View File

@ -106,18 +106,28 @@ let AppManager = exports.AppManager = {
this._listTabsResponse = null;
} else {
this.connection.client.listTabs((response) => {
let front = new AppActorFront(this.connection.client,
response);
front.on("install-progress", this.onInstallProgress);
front.watchApps(() => this.checkIfProjectIsRunning())
.then(() => front.fetchIcons())
.then(() => {
this._appsFront = front;
this.checkIfProjectIsRunning();
this.update("runtime-apps-found");
});
this._listTabsResponse = response;
this.update("list-tabs-response");
if (response.webappsActor) {
let front = new AppActorFront(this.connection.client,
response);
front.on("install-progress", this.onInstallProgress);
front.watchApps(() => this.checkIfProjectIsRunning())
.then(() => {
// This can't be done earlier as many operations
// in the apps actor require watchApps to be called
// first.
this._appsFront = front;
this._listTabsResponse = response;
this.update("list-tabs-response");
return front.fetchIcons();
})
.then(() => {
this.checkIfProjectIsRunning();
this.update("runtime-apps-found");
});
} else {
this._listTabsResponse = response;
this.update("list-tabs-response");
}
});
}
@ -416,6 +426,10 @@ let AppManager = exports.AppManager = {
}
},
runtimeCanHandleApps: function() {
return !!this._appsFront;
},
installAndRunProject: function() {
let project = this.selectedProject;
@ -429,6 +443,11 @@ let AppManager = exports.AppManager = {
return promise.reject("Can't install");
}
if (!this._appsFront) {
console.error("Runtime doesn't have a webappsActor");
return promise.reject("Can't install");
}
return Task.spawn(function* () {
let self = AppManager;

View File

@ -29,7 +29,7 @@
let fakeRuntime = {
type: "USB",
connect: function(connection) {
ok(connection, win.AppManager.connection, "connection is valid");
is(connection, win.AppManager.connection, "connection is valid");
connection.host = null; // force connectPipe
connection.connect();
return promise.resolve();

View File

@ -51,7 +51,7 @@
win.AppManager.runtimeList.usb.push({
connect: function(connection) {
ok(connection, win.AppManager.connection, "connection is valid");
is(connection, win.AppManager.connection, "connection is valid");
connection.host = null; // force connectPipe
connection.connect();
return promise.resolve();
@ -84,6 +84,8 @@
is(Object.keys(DebuggerServer._connections).length, 1, "Connected");
yield waitForUpdate(win, "list-tabs-response");
ok(isPlayActive(), "play button is enabled 1");
ok(!isStopActive(), "stop button is disabled 1");
let oldProject = win.AppManager.selectedProject;