2013-10-02 10:27:14 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Test for DataStore - install/uninstall apps</title>
|
|
|
|
<body>
|
|
|
|
<script type="application/javascript;version=1.7">
|
|
|
|
|
2014-07-16 20:53:23 -07:00
|
|
|
var gHostedManifestURL = 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_app_install.html';
|
|
|
|
|
2013-10-02 10:27:14 -07:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2014-07-16 20:53:23 -07:00
|
|
|
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) {
|
2013-10-02 10:27:14 -07:00
|
|
|
finish();
|
2014-07-16 20:53:23 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var test = tests.shift();
|
|
|
|
test();
|
|
|
|
}
|
|
|
|
|
|
|
|
runTest();
|
2013-10-02 10:27:14 -07:00
|
|
|
</script>
|
|
|
|
</html>
|