|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <meta charset="utf-8"> |
|
5 <title>Test for DataStore - basic operation on a readonly db</title> |
|
6 </head> |
|
7 <body> |
|
8 <p id="display"></p> |
|
9 <div id="content" style="display: none"> |
|
10 |
|
11 </div> |
|
12 <pre id="test"> |
|
13 <script type="application/javascript;version=1.7"> |
|
14 |
|
15 function is(a, b, msg) { |
|
16 alert((a === b ? 'OK' : 'KO') + ' ' + msg) |
|
17 } |
|
18 |
|
19 function ok(a, msg) { |
|
20 alert((a ? 'OK' : 'KO')+ ' ' + msg) |
|
21 } |
|
22 |
|
23 function cbError() { |
|
24 alert('KO error'); |
|
25 } |
|
26 |
|
27 function finish() { |
|
28 alert('DONE'); |
|
29 } |
|
30 |
|
31 function eventListener(obj) { |
|
32 ok(obj, "OnChangeListener is called with data"); |
|
33 ok("revisionId" in obj, "the event contains a revisionId"); |
|
34 ok("id" in obj, "the event contains a id"); |
|
35 ok("operation" in obj, "the event contains a operation"); |
|
36 ok("owner" in obj, "the event contains a owner"); |
|
37 is(obj.owner, 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_changes.html', 'Owner matches'); |
|
38 finish(); |
|
39 } |
|
40 |
|
41 navigator.getDataStores('foo').then(function(stores) { |
|
42 is(stores.length, 1, "getDataStores('foo') returns 1 element"); |
|
43 is(stores[0].name, 'foo', 'The dataStore.name is foo'); |
|
44 |
|
45 stores[0].onchange = eventListener; |
|
46 alert('READY'); |
|
47 }); |
|
48 </script> |
|
49 </pre> |
|
50 </body> |
|
51 </html> |