gecko-dev/dom/apps/tests/file_bug_779982.html

56 строки
1.3 KiB
HTML

<!DOCTYPE html>
<html>
<body>
foobar!
</body>
<script>
var finished = false;
var data = window.location.search.substring(1).split('&');
function finish(value) {
value ? alert('success') : alert('failure');
finished = true;
}
switch (data[0]) {
case "getSelf":
navigator.mozApps.getSelf().onsuccess = function onGetSelf() {
if (data[1] == 'true') {
finish(this.result == null);
} else {
finish(this.result != null);
}
}
break;
case "checkInstalled":
navigator.mozApps.checkInstalled('http://example.org/manifest.webapp').onsuccess = function onCheckInstalled() {
if (data[1] == 'true') {
finish(!this.result);
} else {
finish(!!this.result);
}
}
break;
case "checkInstalledWrong":
var request = navigator.mozApps.checkInstalled('http://something.org/manifest.webapp');
request.onsuccess = function() {
finish(false);
}
request.onerror = function() {
if (this.error.name == "CROSS_ORIGIN_CHECK_NOT_ALLOWED") {
finish(true);
} else {
finish(false);
}
}
break;
default:
finish(false);
break;
}
</script>
</html>