3 function testGetDataStores() {
4 navigator.getDataStores('foo').then(function(stores) {
5 is(stores.length, 1, "getDataStores('foo') returns 1 element");
6 is(stores[0].name, 'foo', 'The dataStore.name is foo');
7 is(stores[0].readOnly, false, 'The dataStore foo is not in readonly');
10 ok("get" in store, "store.get exists");
11 ok("put" in store, "store.put exists");
12 ok("add" in store, "store.add exists");
13 ok("remove" in store, "store.remove exists");
14 ok("clear" in store, "store.clear exists");
15 ok("revisionId" in store, "store.revisionId exists");
16 ok("getLength" in store, "store.getLength exists");
17 ok("sync" in store, "store.sync exists");
25 function testStoreGet(id, value) {
26 gStore.get(id).then(function(what) {
27 ok(true, "store.get() retrieves data");
28 is(what, value, "store.get(" + id + ") returns " + value);
30 ok(false, "store.get(" + id + ") retrieves data");
31 }).then(runTest, cbError);
34 function testStoreAdd(value) {
35 return gStore.add(value).then(function(what) {
36 ok(true, "store.add() is called");
37 ok(what > 0, "store.add() returns something");
42 function testStorePut(value, id) {
43 return gStore.put(value, id).then(function() {
44 ok(true, "store.put() is called");
48 function testStoreGetLength(number) {
49 return gStore.getLength().then(function(n) {
50 is(number, n, "store.getLength() returns the right number");
54 function testStoreRemove(id) {
55 return gStore.remove(id).then(function() {
56 ok(true, "store.remove() is called");
60 function testStoreClear() {
61 return gStore.clear().then(function() {
62 ok(true, "store.clear() is called");
67 // Test for GetDataStore
71 function() { testStoreGet(42, undefined); },
72 function() { testStoreGet(42, undefined); }, // twice
75 function() { testStoreAdd(42).then(function(id) {
76 gId = id; runTest(); }, cbError); },
77 function() { testStoreGet(gId, 42); },
79 // Add + Get - boolean
80 function() { testStoreAdd(true).then(function(id) {
81 gId = id; runTest(); }, cbError); },
82 function() { testStoreGet(gId, true); },
85 function() { testStoreAdd("hello world").then(function(id) {
86 gId = id; runTest(); }, cbError); },
87 function() { testStoreGet(gId, "hello world"); },
90 function() { testStorePut("hello world 2", gId).then(function() {
91 runTest(); }, cbError); },
92 function() { testStoreGet(gId, "hello world 2"); },
95 function() { testStoreGetLength(3).then(function() { runTest(); }, cbError); },
98 function() { testStoreRemove(gId).then(function(what) {
99 runTest(); }, cbError); },
100 function() { testStoreGet(gId, undefined); },
103 function() { testStoreRemove(gId).then(function(what) {
104 runTest(); }, cbError); },
107 function() { testStoreClear().then(function(what) {
108 runTest(); }, cbError); },
117 var test = tests.shift();