mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
a04c521e92
--HG-- rename : dom/datastore/tests/file_app.template.webapp => dom/datastore/tests/file_app2.template.webapp rename : dom/datastore/tests/test_revision.html => dom/datastore/tests/file_revision.html
73 lines
1.8 KiB
HTML
73 lines
1.8 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for DataStore - basic operation on a readonly db</title>
|
|
</head>
|
|
<body>
|
|
<div id="container"></div>
|
|
<script type="application/javascript;version=1.7">
|
|
|
|
function is(a, b, msg) {
|
|
dump((a === b ? 'OK' : 'KO') + ' ' + msg + "\n")
|
|
alert((a === b ? 'OK' : 'KO') + ' ' + msg)
|
|
}
|
|
|
|
function ok(a, msg) {
|
|
alert((a ? 'OK' : 'KO')+ ' ' + msg)
|
|
}
|
|
|
|
function cbError() {
|
|
alert('KO error');
|
|
}
|
|
|
|
function finish() {
|
|
alert('DONE');
|
|
}
|
|
|
|
function runTest() {
|
|
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');
|
|
is(stores[0].readOnly, true, 'The dataStore bar is eadonly');
|
|
|
|
var store = stores[0];
|
|
ok("get" in store, "store.get exists");
|
|
ok("update" in store, "store.update exists");
|
|
ok("add" in store, "store.add exists");
|
|
ok("remove" in store, "store.remove exists");
|
|
ok("clear" in store, "store.clear exists");
|
|
|
|
var f = store.clear();
|
|
f = f.then(cbError, function() {
|
|
ok(true, "store.clear() fails because the db is readonly");
|
|
return store.remove(123);
|
|
});
|
|
|
|
f = f.then(cbError, function() {
|
|
ok(true, "store.remove() fails because the db is readonly");
|
|
return store.add(123, true);
|
|
});
|
|
|
|
f = f.then(cbError, function() {
|
|
ok(true, "store.add() fails because the db is readonly");
|
|
return store.update(123, {});
|
|
})
|
|
|
|
f = f.then(cbError, function() {
|
|
ok(true, "store.update() fails because the db is readonly");
|
|
})
|
|
|
|
f.then(function() {
|
|
// All done.
|
|
ok(true, "All done");
|
|
finish();
|
|
});
|
|
}, cbError);
|
|
}
|
|
|
|
runTest();
|
|
</script>
|
|
</body>
|
|
</html>
|