tenfourfox/dom/datastore/tests/file_app_install.html
Cameron Kaiser c9b2922b70 hello FPR
2017-04-19 00:56:45 -07:00

92 lines
2.7 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for DataStore - install/uninstall apps</title>
<body>
<script type="application/javascript;version=1.7">
var gHostedManifestURL = 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_app_install.html';
function is(a, b, msg) {
alert((a === b ? 'OK' : 'KO') + ' ' + msg)
}
function ok(a, msg) {
alert((a ? 'OK' : 'KO')+ ' ' + msg)
}
function cbError() {
alert('KO error');
}
function finish() {
alert('DONE');
}
var tests = [
// Get datastore with name 'foo'
function() {
navigator.getDataStores('foo').then(function(stores) {
is(stores.length, 1, "getDataStores('foo') returns 1 element");
is(stores[0].name, 'foo', 'The dataStore.name is foo');
ok(stores[0].owner, 'The dataStore.owner exists');
is(stores[0].readOnly, false, 'The dataStore foo is not in readonly');
runTest();
}, cbError);
},
// Get datastore with name 'bar'
function() {
navigator.getDataStores('bar').then(function(stores) {
is(stores.length, 1, "getDataStores('bar') returns 1 element");
is(stores[0].name, 'bar', 'The dataStore.name is bar');
ok(stores[0].owner, 'The dataStore.owner exists');
is(stores[0].readOnly, false, 'The dataStore bar is in readonly');
runTest();
}, cbError);
},
// Get datastore with name 'foo' and a specified owner
function() {
navigator.getDataStores('foo', gHostedManifestURL).then(function(stores) {
is(stores.length, 1, "getDataStores('foo','" + gHostedManifestURL +
"') returns 1 element");
is(stores[0].name, 'foo', 'The dataStore.name is foo');
ok(stores[0].owner, 'The dataStore.owner exists');
is(stores[0].readOnly, false, 'The dataStore foo is not in readonly');
runTest();
}, cbError);
},
// Get datastore with name 'foo' and an arbitrary non-existent owner
function() {
navigator.getDataStores('foo', 'non-existent').then(function(stores) {
is(stores.length, 0, "getDataStores('foo','non-existent') returns 0 element");
runTest();
}, cbError);
},
// Get datastore with an arbitrary non-existent name
function() {
navigator.getDataStores('non-existent').then(function(stores) {
is(stores.length, 0, "getDataStores('non-existent') returns 0 element");
runTest();
}, cbError);
},
];
function runTest() {
if (!tests.length) {
finish();
return;
}
var test = tests.shift();
test();
}
runTest();
</script>
</html>