gecko/dom/datastore/tests/file_bug924104.html
Andrea Marchesini b9a6b6ed55 Bug 924125 - DataStore API is always returning empty objects, r=ehsan
--HG--
rename : dom/datastore/tests/test_basic.html => dom/datastore/tests/test_bug924104.html
2013-10-07 12:09:08 -04:00

78 lines
1.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for bug 924104</title>
</head>
<body>
<div id="container"></div>
<script type="application/javascript;version=1.7">
var gStore;
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');
}
function testGetDataStores() {
navigator.getDataStores('foo').then(function(stores) {
gStore = stores[0];
runTest();
}, cbError);
}
function testBug924104() {
gStore
.add({})
.then(
function(index) {
ok(index, "store.add() created item" + index);
return gStore.get(index);
},
cbError)
.then(
function(obj) {
ok(true, "store.get() works");
var status = false;
try {
obj['foobar'] = 42;
status = true;
} catch(e) {}
ok(status, "Object is editable");
runTest();
},
cbError);
}
var tests = [
testGetDataStores,
testBug924104
];
function runTest() {
if (!tests.length) {
finish();
return;
}
var test = tests.shift();
test();
}
runTest();
</script>
</body>
</html>