|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <meta charset="utf-8"> |
|
5 <title>Test for DataStore - event receiver</title> |
|
6 </head> |
|
7 <body> |
|
8 <script type="application/javascript;version=1.7"> |
|
9 |
|
10 function ok(a, msg) { |
|
11 alert((a ? 'OK' : 'KO') + ' ' + msg) |
|
12 } |
|
13 |
|
14 function is(a, b, msg) { |
|
15 ok(a === b, msg); |
|
16 } |
|
17 |
|
18 function cbError() { |
|
19 alert('KO error'); |
|
20 } |
|
21 |
|
22 function finish() { |
|
23 alert('DONE'); |
|
24 } |
|
25 |
|
26 function eventListener(evt) { |
|
27 ok(evt, "OnChangeListener is called with data"); |
|
28 finish(); |
|
29 } |
|
30 |
|
31 navigator.getDataStores('foo').then(function(stores) { |
|
32 is(stores.length, 1, "getDataStores('foo') returns 1 element"); |
|
33 is(stores[0].name, 'foo', 'The dataStore.name is foo'); |
|
34 is(stores[0].readOnly, false, 'The dataStore foo is not in readonly'); |
|
35 |
|
36 var store = stores[0]; |
|
37 store.onchange = eventListener; |
|
38 alert("READY"); |
|
39 }); |
|
40 |
|
41 </script> |
|
42 </body> |
|
43 </html> |
|
44 |
|
45 |