dom/datastore/tests/file_bug924104.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.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <meta charset="utf-8">
michael@0 5 <title>Test for bug 924104</title>
michael@0 6 </head>
michael@0 7 <body>
michael@0 8 <div id="container"></div>
michael@0 9 <script type="application/javascript;version=1.7">
michael@0 10
michael@0 11 var gStore;
michael@0 12
michael@0 13 function is(a, b, msg) {
michael@0 14 alert((a === b ? 'OK' : 'KO') + ' ' + msg)
michael@0 15 }
michael@0 16
michael@0 17 function ok(a, msg) {
michael@0 18 alert((a ? 'OK' : 'KO')+ ' ' + msg)
michael@0 19 }
michael@0 20
michael@0 21 function cbError() {
michael@0 22 alert('KO error');
michael@0 23 }
michael@0 24
michael@0 25 function finish() {
michael@0 26 alert('DONE');
michael@0 27 }
michael@0 28
michael@0 29 function testGetDataStores() {
michael@0 30 navigator.getDataStores('foo').then(function(stores) {
michael@0 31 gStore = stores[0];
michael@0 32 runTest();
michael@0 33 }, cbError);
michael@0 34 }
michael@0 35
michael@0 36 function testBug924104() {
michael@0 37 gStore
michael@0 38 .add({})
michael@0 39 .then(
michael@0 40 function(index) {
michael@0 41 ok(index, "store.add() created item" + index);
michael@0 42 return gStore.get(index);
michael@0 43 },
michael@0 44 cbError)
michael@0 45 .then(
michael@0 46 function(obj) {
michael@0 47 ok(true, "store.get() works");
michael@0 48 var status = false;
michael@0 49 try {
michael@0 50 obj['foobar'] = 42;
michael@0 51 status = true;
michael@0 52 } catch(e) {}
michael@0 53 ok(status, "Object is editable");
michael@0 54 runTest();
michael@0 55 },
michael@0 56 cbError);
michael@0 57 }
michael@0 58
michael@0 59 var tests = [
michael@0 60 testGetDataStores,
michael@0 61 testBug924104
michael@0 62 ];
michael@0 63
michael@0 64 function runTest() {
michael@0 65 if (!tests.length) {
michael@0 66 finish();
michael@0 67 return;
michael@0 68 }
michael@0 69
michael@0 70 var test = tests.shift();
michael@0 71 test();
michael@0 72 }
michael@0 73
michael@0 74 runTest();
michael@0 75 </script>
michael@0 76 </body>
michael@0 77 </html>

mercurial