dom/datastore/tests/file_bug924104.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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">
    11   var gStore;
    13   function is(a, b, msg) {
    14     alert((a === b ? 'OK' : 'KO') + ' ' + msg)
    15   }
    17   function ok(a, msg) {
    18     alert((a ? 'OK' : 'KO')+ ' ' + msg)
    19   }
    21   function cbError() {
    22     alert('KO error');
    23   }
    25   function finish() {
    26     alert('DONE');
    27   }
    29   function testGetDataStores() {
    30     navigator.getDataStores('foo').then(function(stores) {
    31       gStore = stores[0];
    32       runTest();
    33     }, cbError);
    34   }
    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   }
    59   var tests = [
    60     testGetDataStores,
    61     testBug924104
    62   ];
    64   function runTest() {
    65     if (!tests.length) {
    66       finish();
    67       return;
    68     }
    70     var test = tests.shift();
    71     test();
    72   }
    74   runTest();
    75   </script>
    76 </body>
    77 </html>

mercurial