dom/datastore/tests/file_changes2.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/datastore/tests/file_changes2.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <meta charset="utf-8">
     1.8 +  <title>Test for DataStore - basic operation on a readonly db</title>
     1.9 +</head>
    1.10 +<body>
    1.11 +<p id="display"></p>
    1.12 +<div id="content" style="display: none">
    1.13 +
    1.14 +</div>
    1.15 +<pre id="test">
    1.16 +  <script type="application/javascript;version=1.7">
    1.17 +
    1.18 +  function is(a, b, msg) {
    1.19 +    alert((a === b ? 'OK' : 'KO') + ' ' + msg)
    1.20 +  }
    1.21 +
    1.22 +  function ok(a, msg) {
    1.23 +    alert((a ? 'OK' : 'KO')+ ' ' + msg)
    1.24 +  }
    1.25 +
    1.26 +  function cbError() {
    1.27 +    alert('KO error');
    1.28 +  }
    1.29 +
    1.30 +  function finish() {
    1.31 +    alert('DONE');
    1.32 +  }
    1.33 +
    1.34 +  function eventListener(obj) {
    1.35 +    ok(obj, "OnChangeListener is called with data");
    1.36 +    ok("revisionId" in obj, "the event contains a revisionId");
    1.37 +    ok("id" in obj, "the event contains a id");
    1.38 +    ok("operation" in obj, "the event contains a operation");
    1.39 +    ok("owner" in obj, "the event contains a owner");
    1.40 +    is(obj.owner, 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_changes.html', 'Owner matches');
    1.41 +    finish();
    1.42 +  }
    1.43 +
    1.44 +  navigator.getDataStores('foo').then(function(stores) {
    1.45 +    is(stores.length, 1, "getDataStores('foo') returns 1 element");
    1.46 +    is(stores[0].name, 'foo', 'The dataStore.name is foo');
    1.47 +
    1.48 +    stores[0].onchange = eventListener;
    1.49 +    alert('READY');
    1.50 +  });
    1.51 +  </script>
    1.52 +</pre>
    1.53 +</body>
    1.54 +</html>

mercurial