зеркало из https://github.com/mozilla/pjs.git
bug 739330 - call error handler with NOT_INSTALLED when page tries to uninstall webapp that is not installed; r=fabrice
--HG-- extra : rebase_source : 5ea5510c43d336a23245ad12b7cddbf8a438b164
This commit is contained in:
Родитель
e9b25fc325
Коммит
b23a3b90c7
|
@ -262,7 +262,7 @@ WebappsApplication.prototype = {
|
|||
Services.DOMRequest.fireSuccess(req, msg.origin);
|
||||
break;
|
||||
case "Webapps:Uninstall:Return:KO":
|
||||
Services.DOMRequest.fireError(req, msg.origin);
|
||||
Services.DOMRequest.fireError(req, "NOT_INSTALLED");
|
||||
break;
|
||||
}
|
||||
this.removeRequest(msg.requestID);
|
||||
|
|
|
@ -85,6 +85,8 @@ function subsetOf(resultObj, list) {
|
|||
*/
|
||||
|
||||
function uninstall(appURL, check, next) {
|
||||
var found = false;
|
||||
var finished = false;
|
||||
var pending = navigator.mozApps.getInstalled();
|
||||
pending.onsuccess = function () {
|
||||
var m = this.result;
|
||||
|
@ -99,30 +101,36 @@ function uninstall(appURL, check, next) {
|
|||
try {
|
||||
var secondUninstall = app.uninstall();
|
||||
secondUninstall.onsuccess = function(r) {
|
||||
check(false, "mozApps allowed second uninstall without error");
|
||||
next();
|
||||
};
|
||||
secondUninstall.onerror = function(r) {
|
||||
debug(secondUninstall.error.name);
|
||||
debug(secondUninstall.error.manifestURL);
|
||||
debug("Got second error: " + this.error.name);
|
||||
check(
|
||||
this.error.name == "NOT_INSTALLED",
|
||||
"The second mozApps uninstall should return an error with the name " +
|
||||
"NOT_INSTALLED, not " + this.error.name);
|
||||
next();
|
||||
};
|
||||
}
|
||||
catch(e) {
|
||||
check(e.message == "Not enough arguments \[mozIDOMApplicationRegistry.install\]", "install returned " + e.message);
|
||||
check(false, "Unexpected error calling uninstall: " + e);
|
||||
next();
|
||||
}
|
||||
};
|
||||
pendingUninstall.onerror = function () {
|
||||
check(false);
|
||||
check(false, "Got error in uninstall: " + this.error.name);
|
||||
finished = true;
|
||||
throw('Failed');
|
||||
};
|
||||
}
|
||||
}
|
||||
if (! found) {
|
||||
check(false, "Found no app with manifest URL: " + appURL);
|
||||
}
|
||||
};
|
||||
pending.onerror = function () {
|
||||
check(false, "Unexpected on error called in uninstall " );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,7 +337,6 @@ function debug(msg) {
|
|||
dump(msg + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
function check_event_listener_fired (next) {
|
||||
todo(triggered, "Event Listener fired");
|
||||
triggered = false;
|
||||
|
|
|
@ -59,6 +59,7 @@ function install_super_crazy(next) {
|
|||
}
|
||||
|
||||
function get_self_returns_nothing(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.getSelf(),
|
||||
[{ status: "== \"success\""}],
|
||||
ok,
|
||||
|
@ -66,6 +67,7 @@ function get_self_returns_nothing(next) {
|
|||
}
|
||||
|
||||
function install_wild_crazy(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['wild_crazy'];
|
||||
install(appURL, ok, function() {
|
||||
getInstalled([appURL], ok, next);
|
||||
|
@ -74,8 +76,9 @@ function install_wild_crazy(next) {
|
|||
}
|
||||
|
||||
function uninstall_wild_crazy(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['wild_crazy'];
|
||||
uninstall(appURL, function() {
|
||||
uninstall(appURL, ok, function() {
|
||||
mozAppscb(navigator.mozApps.getInstalled(),
|
||||
[{ status: "== \"success\""}],
|
||||
ok,
|
||||
|
|
Загрузка…
Ссылка в новой задаче