Bug 1000315 - Part 7: App tests automatically confirm uninstallation. r=myk

This commit is contained in:
Ted Clancy (:tedders1) 2014-06-11 14:33:02 -07:00
Родитель fb8f844459
Коммит fe1e3215dd
27 изменённых файлов: 75 добавлений и 27 удалений

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

@ -72,6 +72,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=826058
yield undefined;
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
// Load the app, uninstalled.
checkAppState(null, false, 1, continueTest);

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

@ -44,6 +44,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795164
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
// Keeping track of the number of times `mozApps.mgmt.onuninstall` gets triggered
let uninstallCount = 0;

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

@ -71,6 +71,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=945152
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
// Create app on server side.
createApp(continueTest);
yield undefined;

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

@ -60,6 +60,9 @@ function runTest() {
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
request = navigator.mozApps.mgmt.getAll();
request.onerror = cbError;
request.onsuccess = continueTest;

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

@ -57,6 +57,9 @@ function runTest() {
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
// Test install with three valid receipts
let valid_receipt1 = 'eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTYifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.eZpTEnCLUR3iP3rm9WyJOqx1k66mQaAxqcrvX11r5E0';

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

@ -131,8 +131,10 @@ PackagedTestHelper.setSteps([
SpecialPowers.addPermission("webapps-manage", true, document);
SpecialPowers.addPermission("browser", true, document);
SpecialPowers.autoConfirmAppInstall(() =>
SpecialPowers.pushPrefEnv({set: [["dom.mozBrowserFramesEnabled", true]]},
PackagedTestHelper.next));
SpecialPowers.autoConfirmAppUninstall(() =>
SpecialPowers.pushPrefEnv({set: [["dom.mozBrowserFramesEnabled",
true]]},
PackagedTestHelper.next)));
},
function() {
info("== TEST == Marketplace packaged app from https://marketplace.firefox.com/");

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

@ -140,6 +140,9 @@ function runTest() {
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
setState("setVersion", 1, continueTest);
yield undefined;

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

@ -90,6 +90,10 @@ var steps = [
info("autoConfirmAppInstall");
SpecialPowers.autoConfirmAppInstall(PackagedTestHelper.next);
},
function() {
ok(true, "autoConfirmAppUninstall");
SpecialPowers.autoConfirmAppUninstall(PackagedTestHelper.next);
},
function() {
PackagedTestHelper.setAppVersion(0, PackagedTestHelper.next);
},

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

@ -57,6 +57,9 @@ function runTest() {
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
var request = navigator.mozApps.install(gManifestURL);
request.onerror = cbError;
request.onsuccess = continueTest;

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

@ -106,6 +106,10 @@ var steps = [
info("autoConfirmAppInstall");
SpecialPowers.autoConfirmAppInstall(PackagedTestHelper.next);
},
function() {
info("autoConfirmAppUninstall");
SpecialPowers.autoConfirmAppUninstall(PackagedTestHelper.next);
},
function() {
info("== TEST == Install packaged app");
var miniManifestURL = gSJS + "?" + "app=valid&" + "version=1";

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

@ -44,6 +44,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=830258
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
let request = navigator.mozApps.install(url1);
request.onerror = mozAppsError;
request.onsuccess = continueTest;

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

@ -190,7 +190,9 @@
// No confirmation needed when an app is installed
function() {
SpecialPowers.autoConfirmAppInstall(runTest);
SpecialPowers.autoConfirmAppInstall(() => {
SpecialPowers.autoConfirmAppUninstall(runTest);
});
},
// Installing the app

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

@ -19,7 +19,7 @@
var parent = SpecialPowers.wrap(window).parent;
confirmNextInstall();
confirmNextPopup();
navigator.mozApps.install(parent.url2, null).onsuccess = function onInstall() {
// Give the test page a reference to the installed app, so it can uninstall it
// after it finishes the tests.

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

@ -34,19 +34,22 @@ function runAll(steps) {
next();
}
function confirmNextInstall() {
function confirmNextPopup() {
var Ci = SpecialPowers.Ci;
var popupPanel = SpecialPowers.wrap(window).top.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebNavigation).
QueryInterface(Ci.nsIDocShell).
chromeEventHandler.ownerDocument.defaultView.
PopupNotifications.panel;
var popupNotifications = SpecialPowers.wrap(window).top.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebNavigation).
QueryInterface(Ci.nsIDocShell).
chromeEventHandler.ownerDocument.defaultView.
PopupNotifications;
var popupPanel = popupNotifications.panel;
function onPopupShown() {
popupPanel.removeEventListener("popupshown", onPopupShown, false);
SpecialPowers.wrap(this).childNodes[0].button.doCommand();
popupNotifications._dismiss();
}
popupPanel.addEventListener("popupshown", onPopupShown, false);
}

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

@ -43,7 +43,7 @@ ppmm.addMessageListener("Webapps:Install", mmListener);
// We call this here, even though the app is installed by the helper page,
// because the helper page redirect would cause its install listener to unload
// before it can confirm the install.
confirmNextInstall();
confirmNextPopup();
</script>

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

@ -43,7 +43,7 @@ runAll(steps);
* the app itself is from a different origin (http://test1.example.com).
*/
function installAppFromOwnOrigin(next) {
confirmNextInstall();
confirmNextPopup();
navigator.mozApps.install(url1, null).onsuccess = function onInstall() {
app1 = this.result;
next();
@ -93,7 +93,9 @@ function getAll(next) {
}
function uninstall(next) {
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(app1).onsuccess = function onUninstallApp1() {
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(app2).onsuccess = function onUninstallApp2() {
next();
};

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

@ -76,11 +76,11 @@ function getNotInstalled(next) {
// Add an app to the appregistry
function installApp(next) {
confirmNextInstall();
confirmNextPopup();
navigator.mozApps.install(url, null).onsuccess = function onInstall() {
app = this.result;
next();
}
};
}
// Call navigator.mozApps.mgmt.getNotInstalled and make sure there is one more.
@ -128,6 +128,7 @@ function unmonkeyPatchDOMApplicationRegistry(next) {
// Remove the app from the appregistry
function uninstallApp(next) {
confirmNextPopup();
window.navigator.mozApps.mgmt.uninstall(app).onsuccess = function onUninstall() {
app = null;
next();

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

@ -45,7 +45,7 @@ function install(next) {
var beforehand = Date.now();
const fuzzySpan = 250;
confirmNextInstall();
confirmNextPopup();
navigator.mozApps.install(url, null).onsuccess = function onInstall() {
app = this.result;
@ -84,6 +84,7 @@ function getSelf(next) {
}
function uninstall(next) {
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(app).onsuccess = function onUninstall() {
// Try to retrieve the app we just uninstalled, to make sure it no longer
// exists in the registry.

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

@ -69,7 +69,7 @@ function invalidManifest(next) {
function permissionDenied(next) {
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/no_delegated_install.webapp";
confirmNextInstall();
confirmNextPopup();
var request = navigator.mozApps.install(url, null);
request.onerror = function onInstallError() {
@ -79,6 +79,7 @@ function permissionDenied(next) {
request.onsuccess = function onInstall() {
todo(false, "manifest without installs_allowed_from fails");
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() {
next();
};
@ -97,6 +98,7 @@ function invalidContent(next) {
request.onsuccess = function onInstall() {
ok(false, "manifest with bad content type should fail");
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() {
next();
};
@ -206,6 +208,7 @@ function originNotAllowed(next) {
request.onsuccess = function onInstall() {
ok(false, "test should fail because of installs_allowed_from");
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() {
next();
};
@ -215,7 +218,7 @@ function originNotAllowed(next) {
function originAllowed(next) {
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/installs_allowed_from_chrome_mochitests.webapp";
confirmNextInstall();
confirmNextPopup();
var request = navigator.mozApps.install(url, null);
request.onerror = function onInstallError() {
@ -225,6 +228,7 @@ function originAllowed(next) {
request.onsuccess = function onInstall() {
ok(true, "test origin is in installs_allowed_from");
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() {
next();
};

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

@ -22,12 +22,13 @@ SimpleTest.waitForExplicitFinish();
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/utf8.webapp";
confirmNextInstall();
confirmNextPopup();
navigator.mozApps.install(url, null).onsuccess = function onInstall() {
is(this.result.manifest.name, "TheBOM ゲゴケ゚セニツ゚ヅヂチ", "manifest.name");
is(this.result.manifest.description, "This App is THE BOM, yo. ヅヂチ",
"manifest.description");
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() {
SimpleTest.finish();
}

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

@ -45,7 +45,7 @@ function install(next) {
var beforehand = Date.now();
const fuzzySpan = 250;
confirmNextInstall();
confirmNextPopup();
navigator.mozApps.install(url, null).onsuccess = function onInstall() {
app = this.result;
@ -84,6 +84,7 @@ function getSelf(next) {
}
function uninstall(next) {
confirmNextPopup();
navigator.mozApps.mgmt.uninstall(app).onsuccess = function onUninstall() {
// Try to retrieve the app we just uninstalled, to make sure it no longer
// exists in the registry.

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

@ -502,7 +502,7 @@ function generateDataURI(aFile) {
btoa(stream.readBytes(stream.available()));
}
function confirmNextInstall() {
function confirmNextPopup() {
let popupPanel = window.top.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebNavigation).
QueryInterface(Ci.nsIDocShell).

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

@ -78,7 +78,7 @@ let runTest = Task.async(function*() {
yield setMacRootInstallDir(OS.Path.join(OS.Constants.Path.homeDir, "Applications"));
}
confirmNextInstall();
confirmNextPopup();
let request = navigator.mozApps.installPackage(app.manifestURL);

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

@ -78,7 +78,7 @@ let runTest = Task.async(function*() {
yield setMacRootInstallDir(OS.Path.join(OS.Constants.Path.homeDir, "Applications"));
}
confirmNextInstall();
confirmNextPopup();
let (request = navigator.mozApps.installPackage(app.manifestURL)) {
let (deferred = Promise.defer()) {
@ -110,7 +110,7 @@ let runTest = Task.async(function*() {
is(WebappOSUtils.launch(app), false, "Launch fails");
confirmNextInstall();
confirmNextPopup();
let (request = navigator.mozApps.installPackage(app.manifestURL)) {
let (deferred = Promise.defer()) {

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

@ -56,7 +56,7 @@ let runTest = Task.async(function*() {
yield setMacRootInstallDir(OS.Path.join(OS.Constants.Path.homeDir, "Applications"));
}
confirmNextInstall();
confirmNextPopup();
yield setState("Version", 1);

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

@ -56,7 +56,7 @@ let runTest = Task.async(function*() {
yield setMacRootInstallDir(OS.Path.join(OS.Constants.Path.homeDir, "Applications"));
}
confirmNextInstall();
confirmNextPopup();
let request = navigator.mozApps.install(app.manifestURL);

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

@ -56,7 +56,7 @@ let runTest = Task.async(function*() {
yield setMacRootInstallDir(OS.Path.join(OS.Constants.Path.homeDir, "Applications"));
}
confirmNextInstall();
confirmNextPopup();
yield setState("Version", 1);