Bug 785161 - Stop uninstalling all installed apps in WebApps tests. r=jlebar

This commit is contained in:
Mounir Lamouri 2012-08-23 11:46:38 -07:00
Родитель 8e092dc2e5
Коммит bfd18940bb
8 изменённых файлов: 61 добавлений и 120 удалений

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

@ -105,7 +105,6 @@ function getOrigin(url) {
function tearDown() {
debug("in " + arguments.callee.name);
uninstallAll();
popupNotifications.panel.removeEventListener("popupshown", mainCommand, false);
SpecialPowers.clearUserPref('browser.mozApps.installer.dry_run');
DOMApplicationRegistry.allAppsLaunchable = originalAAL;

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

@ -34,41 +34,6 @@ function onIframeLoad(name, check, next) {
document.getElementById(name).contentWindow.wrappedJSObject.readFile = readFile;
}
/**
* Uninstall All uninstalls all Apps
* @next The next operation to jump to, this might need to be invoked by the iframe when the test has completed
*/
function uninstallAll(next) {
var pendingGetAll = navigator.mozApps.mgmt.getAll();
pendingGetAll.onsuccess = function() {
var m = this.result;
var total = m.length;
var finished = (total === 0);
debug("total = " + total);
for (var i=0; i < m.length; i++) {
var app = m[i];
var pendingUninstall = app.uninstall();
pendingUninstall.onsuccess = function(r) {
finished = (--total === 0);
if(finished == true) {
next();
}
};
pendingUninstall.onerror = function () {
finished = true;
throw('Failed');
if(finished == true) {
next();
}
};
}
if(finished == true && total == 0) {
next();
}
}
}
function subsetOf(resultObj, list) {
var returnObj = {} ;
for (var i=0; i < list.length; i++) {

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

@ -26,7 +26,7 @@
<script>
steps = [setUp, verify_no_apps, get_installed_returns_nothing, install_super_crazy, check_event_listener_fired, get_self_returns_nothing,
steps = [get_installed_returns_nothing, install_super_crazy, check_event_listener_fired, get_self_returns_nothing,
get_self_on_domain, install_on_domain, check_event_listener_fired, get_all_installed,
get_installed_on_domain, uninstall_on_domain, get_all_on_domain, tearDown];
var iframes_loaded = 0 ;
@ -39,21 +39,6 @@ function go() {
}
function setUp(next) {
debug("in " + arguments.callee.name);
uninstallAll(next);
}
function verify_no_apps(next) {
debug("in " + arguments.callee.name);
mozAppscb(navigator.mozApps.mgmt.getAll(),
[{}],
"success",
ok,
next);
}
function get_installed_returns_nothing(next) {
debug("in " + arguments.callee.name);
mozAppscb(navigator.mozApps.getInstalled(),

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

@ -15,24 +15,15 @@
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Webapps.jsm");
let notInstalled = 0;
let _isLaunchable;
let steps = [
cleanUp, installApp, monkeyPatchDOMApplicationRegistry, getNotInstalled,
unmonkeyPatchDOMApplicationRegistry, cleanUp, tearDown
monkeyPatchDOMApplicationRegistry, getNotInstalled, installApp,
compareNotInstalled, unmonkeyPatchDOMApplicationRegistry, cleanUp, tearDown
];
runAll(steps);
// Remove all installed apps and apps from the appregistry
function cleanUp (next) {
uninstallAll(next);
}
// Add an app to the appregistry
function installApp (next) {
let appURL = SERVERS["super_crazy"];
install(appURL, ok, next);
}
// Monkey patch DOMApplicationRegistry._isLaunchable for testing.
// This way, we don't have to create a platform specific application with a
// status other than "installed".
@ -44,8 +35,22 @@ function monkeyPatchDOMApplicationRegistry (next) {
next();
}
// Call navigator.mozApps.mgmt.getNotInstalled
// Call navigator.mozApps.mgmt.getNotInstalled and save the result.
function getNotInstalled (next) {
window.navigator.mozApps.mgmt.getNotInstalled().onsuccess = function() {
notInstalled = this.result.length;
next();
};
}
// Add an app to the appregistry
function installApp (next) {
let appURL = SERVERS["super_crazy"];
install(appURL, ok, next);
}
// Call navigator.mozApps.mgmt.getNotInstalled and make sure there is one more.
function compareNotInstalled (next) {
let results;
function getNotInstalledError () {
ok(false, "window.mozApps.mgmt.getNotInstalled onerror called");
@ -53,12 +58,11 @@ function getNotInstalled (next) {
}
function getNotInstalledSuccess () {
ok(true, "window.mozApps.mgmt.getNotInstalled onsuccess called");
if (this.result.length === 1) {
ok(true, "got the single notInstalled app back")
is(this.result[0].origin, "http://www.example.com",
is(this.result.length, notInstalled + 1, "should get one more notInstalled app");
if (this.result.length > 0) {
is(this.result[this.result.length-1].origin, "http://www.example.com",
"getNotInstalled returned the expected app");
} else {
ok(false, "got an unexpected result from the call to getNotInstalled");
}
next();
}
@ -86,5 +90,12 @@ function unmonkeyPatchDOMApplicationRegistry (next) {
}
next();
}
// Remove installed app.
function cleanUp (next) {
let appURL = SERVERS["super_crazy"];
uninstall(appURL, ok, next);
}
</script>
</window>

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

@ -24,25 +24,11 @@
<script>
steps = [setUp, verify_no_apps, get_installed_returns_nothing, install_super_crazy, get_self_returns_nothing,
steps = [get_installed_returns_nothing, install_super_crazy, get_self_returns_nothing,
install_wild_crazy, uninstall_wild_crazy, tearDown];
runAll(steps);
function setUp(next) {
debug("in " + arguments.callee.name);
uninstallAll(next);
}
function verify_no_apps(next) {
debug("in " + arguments.callee.name);
mozAppscb(navigator.mozApps.mgmt.getAll(),
[{}],
"success",
ok,
next);
}
function get_installed_returns_nothing(next) {
debug("in " + arguments.callee.name);
mozAppscb(navigator.mozApps.getInstalled(),

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

@ -26,13 +26,8 @@ function go() {
runAll(steps);
}
steps = [setUp, no_args, parse_error, invalid_manifest, permission_denied, invalid_content,
mgmt_api_errors, mgmt_api_add_listener, tearDown];
function setUp(next) {
debug("in " + arguments.callee.name);
uninstallAll(next);
}
steps = [no_args, parse_error, invalid_manifest, permission_denied, invalid_content,
mgmt_api_errors, mgmt_api_add_listener, uninstall_apps, tearDown];
function no_args(next) {
debug("in " + arguments.callee.name);
@ -80,6 +75,15 @@ function mgmt_api_add_listener(next) {
document.getElementById("no_delegated_install").contentWindow.postMessage("mgmt.event_error", '*');
}
function uninstall_apps(next) {
debug("in " + arguments.callee.name);
var appURL = SERVERS['bad_content_type'];
uninstall(appURL, ok, function() {
appURL = SERVERS['no_delegated_install'];
uninstall(appURL, ok, function() { next(); });
});
}
</script>
</window>

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

@ -22,16 +22,10 @@
<script>
steps = [setUp, install_super_crazy, tearDown];
steps = [install_super_crazy, uninstall_super_crazy, tearDown];
runAll(steps);
function setUp(next) {
debug("in " + arguments.callee.name);
uninstallAll(next);
}
function install_super_crazy(next) {
debug("in " + arguments.callee.name);
var appURL = SERVERS['super_crazy'];
@ -53,6 +47,12 @@ function install_super_crazy(next) {
};
}
function uninstall_super_crazy(next) {
debug("in " + arguments.callee.name);
var appURL = SERVERS['super_crazy'];
uninstall(appURL, ok, function() { next(); });
}
</script>
</window>

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

@ -22,31 +22,16 @@
<script>
steps = [setUp, verify_no_apps, get_installed_returns_nothing, install_bom, tearDown];
steps = [get_installed_returns_nothing, install_bom, uninstall_bom, tearDown];
runAll(steps);
function setUp(next) {
debug("in " + arguments.callee.name);
uninstallAll(next);
}
function verify_no_apps(next) {
debug("in " + arguments.callee.name);
mozAppscb(navigator.mozApps.mgmt.getAll(),
[{}],
"success",
ok,
next);
}
function get_installed_returns_nothing(next) {
debug("in " + arguments.callee.name);
mozAppscb(navigator.mozApps.getInstalled(),
[{}],
"success",
ok,
next);
navigator.mozApps.getInstalled().onsuccess = function() {
is(this.result.length, 0, "should get no installed app");
next();
};
}
function install_bom(next) {
@ -62,6 +47,12 @@ function install_bom(next) {
};
}
function uninstall_bom(next) {
debug("in " + arguments.callee.name);
var appURL = SERVERS['manifest_with_bom'];
uninstall(appURL, ok, function() { next(); });
}
</script>
</window>