Backed out changeset 28664fb86b3c (bug 1036847) for causing frequent OSX mochitest timeouts.

This commit is contained in:
Ryan VanderMeulen 2014-07-14 10:44:06 -04:00
parent 50869bf682
commit 15a75d5bb5
3 changed files with 24 additions and 122 deletions

View File

@ -20,23 +20,12 @@ var gDevUrl = "http://dev.url";
function handleRequest(request, response) {
var query = getQuery(request);
response.setHeader("Access-Control-Allow-Origin", "*", false);
var packageSize = ("packageSize" in query) ? query.packageSize : 0;
var appName = ("appName" in query) ? query.appName : gAppName;
var devName = ("devName" in query) ? query.devName : gDevName;
var devUrl = ("devUrl" in query) ? query.devUrl : gDevUrl;
// allowCancel just means deliver the file slowly so we have time to cancel it
var allowCancel = "allowCancel" in query;
var getPackage = "getPackage" in query;
var alreadyDeferred = Number(getState("alreadyDeferred"));
if (allowCancel && getPackage && !alreadyDeferred) {
// Only do this for the actual package delivery.
response.processAsync();
// And to avoid timer problems, only do this once.
setState("alreadyDeferred", "1");
}
response.setHeader("Access-Control-Allow-Origin", "*", false);
// If this is a version update, update state, prepare the manifest,
// the application package and return.
@ -47,8 +36,7 @@ function handleRequest(request, response) {
var packageName = "test_packaged_app_" + packageVersion + ".zip";
setState("packageName", packageName);
var packagePath = "/" + gBasePath + "file_packaged_app.sjs?" +
(allowCancel?"allowCancel&": "") + "getPackage=" +
var packagePath = "/" + gBasePath + "file_packaged_app.sjs?getPackage=" +
packageName;
setState("packagePath", packagePath);
@ -96,19 +84,11 @@ function handleRequest(request, response) {
response.setHeader("Etag", etag, false);
// Serve the application package corresponding to the requested app version.
if (getPackage) {
if ("getPackage" in query) {
var resource = readFile(packageName, true);
response.setHeader("Content-Type",
"Content-Type: application/java-archive", false);
if (allowCancel && !alreadyDeferred) {
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback(function (aTimer) {
response.write(resource);
response.finish();
}, 3000, Ci.nsITimer.TYPE_ONE_SHOT);
} else {
response.write(resource);
}
response.write(resource);
return;
}

View File

@ -57,17 +57,13 @@ var PackagedTestHelper = (function PackagedTestHelper() {
finish();
}
function setAppVersion(aVersion, aCb, aDontUpdatePackage, aAllowCancel) {
function setAppVersion(aVersion, aCb, aDontUpdatePackage) {
var xhr = new XMLHttpRequest();
var dontUpdate = "";
var allowCancel = "";
if (aDontUpdatePackage) {
dontUpdate = "&dontUpdatePackage=1";
}
if (aAllowCancel) {
allowCancel= "&allowCancel=1";
}
var url = gSJS + "?setVersion=" + aVersion + dontUpdate + allowCancel;
var url = gSJS + "?setVersion=" + aVersion + dontUpdate;
xhr.addEventListener("load", function() {
is(xhr.responseText, "OK", "setAppVersion OK");
aCb();

View File

@ -34,7 +34,7 @@ function checkAppInstallError(aMiniManifestURL, aExpectedError) {
req.onerror = function(evt) {
var error = evt.target.error.name;
if (error == aExpectedError) {
info("Got expected " + aExpectedError);
ok(true, "Got expected " + aExpectedError);
PackagedTestHelper.next();
} else {
ok(false, "Got unexpected " + error);
@ -46,7 +46,7 @@ function checkAppInstallError(aMiniManifestURL, aExpectedError) {
function checkUninstallApp(aApp) {
var req = navigator.mozApps.mgmt.uninstall(aApp);
req.onsuccess = function() {
info("App uninstalled");
ok(true, "App uninstalled");
aApp.ondownloadsuccess = null;
aApp.ondownloaderror = null;
aApp.onprogress = null;
@ -83,11 +83,11 @@ var steps = [
// Set up
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.addPermission("webapps-manage", true, document);
info("Set up");
ok(true, "Set up");
PackagedTestHelper.next();
},
function() {
info("autoConfirmAppInstall");
ok(true, "autoConfirmAppInstall");
SpecialPowers.autoConfirmAppInstall(PackagedTestHelper.next);
},
function() {
@ -96,17 +96,17 @@ var steps = [
function() {
// Bug 927699 - navigator.mozApps.install(url) lets NS_ERROR_FAILURE onto
// the web.
info("== TEST == INVALID_URL");
ok(true, "== TEST == INVALID_URL");
checkAppInstallError("", "INVALID_URL");
},
function() {
// Test network error.
info("== TEST == Network error");
ok(true, "== TEST == Network error");
checkAppInstallError("http://notvalidurl", "NETWORK_ERROR");
},
function() {
// Test wrong mini-manifest content type.
info("== TEST == Not valid mini-manifest content type");
ok(true, "== TEST == Not valid mini-manifest content type");
var miniManifestURL = PackagedTestHelper.gSJS +
"?getManifest=true" +
"&noManifestContentType=true";
@ -114,7 +114,7 @@ var steps = [
},
function() {
// Test mini-manifest 'size' value is not number. Bug 839435.
info("== TEST == Size value is not a number");
ok(true, "== TEST == Size value is not a number");
var miniManifestURL = PackagedTestHelper.gSJS +
"?getManifest=true" +
"&packageSize=\"NotANumber\"";
@ -122,7 +122,7 @@ var steps = [
},
function() {
// Test mini-manifest negative 'size' value. Bug 839435.
info("== TEST == Negative size value");
ok(true, "== TEST == Negative size value");
var miniManifestURL = PackagedTestHelper.gSJS +
"?getManifest=true" +
"&packageSize=-1";
@ -130,7 +130,7 @@ var steps = [
},
function() {
// Test wrong package path
info("== TEST == Installing app with wrong package path");
ok(true, "== TEST == Installing app with wrong package path");
var miniManifestURL = PackagedTestHelper.gSJS +
"?getManifest=true" +
"&wrongPackagePath=true";
@ -138,7 +138,7 @@ var steps = [
},
function() {
// Test no manifest in zip file.
info("== TEST == No manifest in the zip file");
ok(true, "== TEST == No manifest in the zip file");
var miniManifestURL = PackagedTestHelper.gSJS + "?getManifest=true";
PackagedTestHelper.checkAppDownloadError(miniManifestURL,
"MISSING_MANIFEST", 0, true, true,
@ -150,7 +150,7 @@ var steps = [
function() {
// Test mini-manifest app name is different from the webapp manifest name.
// Bug 844243.
info("== TEST == Mini-manifest app name is different from webapp " +
ok(true, "== TEST == Mini-manifest app name is different from webapp " +
"manifest name");
var miniManifestURL = PackagedTestHelper.gSJS +
"?getManifest=true" +
@ -187,11 +187,11 @@ var steps = [
PackagedTestHelper.setAppVersion(2, PackagedTestHelper.next);
},
function() {
info("== TEST == Install packaged app");
ok(true, "== TEST == Install packaged app");
var miniManifestURL = PackagedTestHelper.gSJS +
"?getManifest=true";
navigator.mozApps.mgmt.oninstall = function(evt) {
info("Got oninstall event");
ok(true, "Got oninstall event");
PackagedTestHelper.gApp = evt.application;
PackagedTestHelper.gApp.ondownloaderror = function() {
ok(false, "Download error " +
@ -199,7 +199,7 @@ var steps = [
PackagedTestHelper.finish();
};
PackagedTestHelper.gApp.ondownloadsuccess = function() {
info("App downloaded");
ok(true, "App downloaded");
var expected = {
name: PackagedTestHelper.gAppName,
manifestURL: miniManifestURL,
@ -220,85 +220,11 @@ var steps = [
var request = navigator.mozApps.installPackage(miniManifestURL);
request.onerror = PackagedTestHelper.mozAppsError;
request.onsuccess = function() {
info("Application installed");
ok(true, "Application installed");
};
},
function() {
PackagedTestHelper.setAppVersion(3, PackagedTestHelper.next, false, true);
},
function() {
info("== TEST == Install packaged app with a cancel/resume");
var miniManifestURL = PackagedTestHelper.gSJS +
"?getManifest=true&allowCancel";
navigator.mozApps.mgmt.oninstall = function(evt) {
info("Got oninstall event");
PackagedTestHelper.gApp = evt.application;
PackagedTestHelper.gApp.onprogress = function() {
// Let's try cancelling and resuming the download later on.
PackagedTestHelper.gApp.cancelDownload();
// And only do this once.
PackagedTestHelper.gApp.onprogress = null;
};
var alreadyCancelled = false;
PackagedTestHelper.gApp.ondownloaderror = function() {
ok(!alreadyCancelled, "The download should be cancelled only once!");
is(PackagedTestHelper.gApp.downloadError.name, "DOWNLOAD_CANCELED",
"Download error " + PackagedTestHelper.gApp.downloadError.name);
if (!alreadyCancelled) {
PackagedTestHelper.gApp.download();
alreadyCancelled = true;
}
};
PackagedTestHelper.gApp.ondownloadsuccess = function() {
info("App downloaded");
// We could try also applying the download we just made.
var expected = {
name: PackagedTestHelper.gAppName,
manifestURL: miniManifestURL,
installOrigin: PackagedTestHelper.gInstallOrigin,
progress: 0,
installState: "pending",
downloadAvailable: false,
downloading: false,
downloadSize: 0,
size: 0,
readyToApplyDownload: true
};
PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, 3, expected,
true, false, function() {});
};
PackagedTestHelper.gApp.ondownloadapplied = function() {
info("App download applied.");
var expected = {
name: PackagedTestHelper.gAppName,
manifestURL: miniManifestURL,
installOrigin: PackagedTestHelper.gInstallOrigin,
progress: 0,
installState: "installed",
downloadAvailable: false,
downloading: false,
downloadSize: 0,
size: 0,
readyToApplyDownload: false
};
PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, 3, expected,
true, false, PackagedTestHelper.next);
}
};
var request = navigator.mozApps.installPackage(miniManifestURL);
request.onerror = PackagedTestHelper.mozAppsError;
request.onsuccess = function() {
info("Application installed");
};
},
function() {
info("all done!\n");
ok(true, "all done!\n");
PackagedTestHelper.finish();
}
];