dom/datastore/tests/file_readonly.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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   <div id="container"></div>
     9   <script type="application/javascript;version=1.7">
    11   function is(a, b, msg) {
    12     dump((a === b ? 'OK' : 'KO') + ' ' + msg + "\n")
    13     alert((a === b ? 'OK' : 'KO') + ' ' + msg)
    14   }
    16   function ok(a, msg) {
    17     alert((a ? 'OK' : 'KO')+ ' ' + msg)
    18   }
    20   function cbError() {
    21     alert('KO error');
    22   }
    24   function finish() {
    25     alert('DONE');
    26   }
    28   function runTest() {
    29     navigator.getDataStores('bar').then(function(stores) {
    30       is(stores.length, 1, "getDataStores('bar') returns 1 element");
    31       is(stores[0].name, 'bar', 'The dataStore.name is bar');
    32       is(stores[0].readOnly, true, 'The dataStore bar is eadonly');
    34       var store = stores[0];
    35       ok("get" in store, "store.get exists");
    36       ok("put" in store, "store.put exists");
    37       ok("add" in store, "store.add exists");
    38       ok("remove" in store, "store.remove exists");
    39       ok("clear" in store, "store.clear exists");
    41       var f = store.clear();
    42       f = f.then(cbError, function() {
    43         ok(true, "store.clear() fails because the db is readonly");
    44         return store.remove(123);
    45       });
    47       f = f.then(cbError, function() {
    48         ok(true, "store.remove() fails because the db is readonly");
    49         return store.add(123, true);
    50       });
    52       f = f.then(cbError, function() {
    53         ok(true, "store.add() fails because the db is readonly");
    54         return store.put({}, 123);
    55       })
    57       f = f.then(cbError, function() {
    58         ok(true, "store.put() fails because the db is readonly");
    59       })
    61       f.then(function() {
    62         // All done.
    63         ok(true, "All done");
    64         finish();
    65       });
    66     }, cbError);
    67   }
    69   runTest();
    70   </script>
    71 </body>
    72 </html>

mercurial