Bug 1250453 - Remove getNotInstalled test. r=myk

This commit is contained in:
Marco Castelluccio 2016-03-10 11:12:24 +00:00
parent 8b7e3c2020
commit 8c064c8da2
2 changed files with 0 additions and 140 deletions

View File

@ -16,7 +16,6 @@ support-files =
[test_bug_945152.html]
skip-if = os != 'linux'
[test_cross_origin.xul]
[test_getNotInstalled.xul]
[test_install_app.xul]
[test_install_errors.xul]
[test_install_utf8.xul]

View File

@ -1,139 +0,0 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Mozilla Bug 781379">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="head.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
target="_blank">Mozilla Bug 781379</a>
</body>
<script type="application/javascript;version=1.8">
Cu.import("resource://gre/modules/Webapps.jsm");
// We use a different origin than other webapps test files because we compare
// the number of apps before and after installing this one; and if a test file
// installs our app and then doesn't uninstall it (f.e. because it isn't written
// to clean up after itself, or because it throws an exception or times out),
// then this test will *reinstall* the app, and the number of apps won't change,
// which will look like a failure in this test although it's actually a failure
// in the other one.
//
// Using a different origin here isn't a foolproof solution, as another test
// could start using it. Reviewer vigilance is required! And to anyone reading
// this: don't use this origin without good reason and due consideration for
// the potential consequences!
//
// Alternately, we could define a test-specific domain, getNotInstalled.com,
// in source/build/pgo/server-locations.txt. But that seems like overkill,
// and this problem will go away once we support multiple apps per origin,
// since then we can make this test install its own personal webapp from any
// origin.
//
let url = "http://example.com/chrome/dom/apps/tests/apps/basic.webapp";
let app, notInstalled, _isLaunchable;
let steps = [
monkeyPatchDOMApplicationRegistry,
getNotInstalled,
installApp,
compareNotInstalled,
unmonkeyPatchDOMApplicationRegistry,
uninstallApp,
];
runAll(steps);
// Monkey patch DOMApplicationRegistry._isLaunchable for testing.
// This way, we don't have to create a platform specific application with a
// status other than "installed".
function monkeyPatchDOMApplicationRegistry(next) {
_isLaunchable = DOMApplicationRegistry._isLaunchable;
DOMApplicationRegistry._isLaunchable = function mockIsLaunchable(aOrigin) {
return false;
}
next();
}
// Call navigator.mozApps.mgmt.getNotInstalled and save the result.
function getNotInstalled(next) {
window.navigator.mozApps.mgmt.getNotInstalled().onsuccess =
function onGetNotInstalled() {
notInstalled = this.result.length;
next();
};
}
// Add an app to the appregistry
function installApp(next) {
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.
function compareNotInstalled(next) {
let results;
function getNotInstalledError() {
ok(false, "window.mozApps.mgmt.getNotInstalled onerror called");
next();
}
function getNotInstalledSuccess() {
ok(true, "window.mozApps.mgmt.getNotInstalled onsuccess called");
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://example.com",
"getNotInstalled returned the expected app");
}
next();
}
let type = typeof window.navigator.mozApps.getNotInstalled;
is(type, "undefined", "getNotInstalled moved from window.navigator");
type = typeof window.navigator.mozApps.mgmt.getNotInstalled;
if (type === "function") {
is(type, "function", "getNotInstalled moved to window.navigator.mgmt");
results = window.navigator.mozApps.mgmt.getNotInstalled();
results.onerror = getNotInstalledError;
results.onsuccess = getNotInstalledSuccess;
} else {
ok(false, "getNotInstalled not a function");
next();
}
}
function unmonkeyPatchDOMApplicationRegistry(next) {
if (typeof _isLaunchable === "function") {
DOMApplicationRegistry._isLaunchable = _isLaunchable;
ok(true, "restored DOMApplicationRegistry._isLaunchable");
} else {
ok(false, "can't restore DOMApplicationRegistry._isLaunchable");
}
next();
}
// Remove the app from the appregistry
function uninstallApp(next) {
confirmNextPopup();
window.navigator.mozApps.mgmt.uninstall(app).onsuccess = function onUninstall() {
app = null;
next();
}
}
</script>
</window>