dom/datastore/tests/file_bug924104.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:80f24a0d9fe6
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Test for bug 924104</title>
6 </head>
7 <body>
8 <div id="container"></div>
9 <script type="application/javascript;version=1.7">
10
11 var gStore;
12
13 function is(a, b, msg) {
14 alert((a === b ? 'OK' : 'KO') + ' ' + msg)
15 }
16
17 function ok(a, msg) {
18 alert((a ? 'OK' : 'KO')+ ' ' + msg)
19 }
20
21 function cbError() {
22 alert('KO error');
23 }
24
25 function finish() {
26 alert('DONE');
27 }
28
29 function testGetDataStores() {
30 navigator.getDataStores('foo').then(function(stores) {
31 gStore = stores[0];
32 runTest();
33 }, cbError);
34 }
35
36 function testBug924104() {
37 gStore
38 .add({})
39 .then(
40 function(index) {
41 ok(index, "store.add() created item" + index);
42 return gStore.get(index);
43 },
44 cbError)
45 .then(
46 function(obj) {
47 ok(true, "store.get() works");
48 var status = false;
49 try {
50 obj['foobar'] = 42;
51 status = true;
52 } catch(e) {}
53 ok(status, "Object is editable");
54 runTest();
55 },
56 cbError);
57 }
58
59 var tests = [
60 testGetDataStores,
61 testBug924104
62 ];
63
64 function runTest() {
65 if (!tests.length) {
66 finish();
67 return;
68 }
69
70 var test = tests.shift();
71 test();
72 }
73
74 runTest();
75 </script>
76 </body>
77 </html>

mercurial