1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/datastore/tests/file_bug924104.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <meta charset="utf-8"> 1.8 + <title>Test for bug 924104</title> 1.9 +</head> 1.10 +<body> 1.11 +<div id="container"></div> 1.12 + <script type="application/javascript;version=1.7"> 1.13 + 1.14 + var gStore; 1.15 + 1.16 + function is(a, b, msg) { 1.17 + alert((a === b ? 'OK' : 'KO') + ' ' + msg) 1.18 + } 1.19 + 1.20 + function ok(a, msg) { 1.21 + alert((a ? 'OK' : 'KO')+ ' ' + msg) 1.22 + } 1.23 + 1.24 + function cbError() { 1.25 + alert('KO error'); 1.26 + } 1.27 + 1.28 + function finish() { 1.29 + alert('DONE'); 1.30 + } 1.31 + 1.32 + function testGetDataStores() { 1.33 + navigator.getDataStores('foo').then(function(stores) { 1.34 + gStore = stores[0]; 1.35 + runTest(); 1.36 + }, cbError); 1.37 + } 1.38 + 1.39 + function testBug924104() { 1.40 + gStore 1.41 + .add({}) 1.42 + .then( 1.43 + function(index) { 1.44 + ok(index, "store.add() created item" + index); 1.45 + return gStore.get(index); 1.46 + }, 1.47 + cbError) 1.48 + .then( 1.49 + function(obj) { 1.50 + ok(true, "store.get() works"); 1.51 + var status = false; 1.52 + try { 1.53 + obj['foobar'] = 42; 1.54 + status = true; 1.55 + } catch(e) {} 1.56 + ok(status, "Object is editable"); 1.57 + runTest(); 1.58 + }, 1.59 + cbError); 1.60 + } 1.61 + 1.62 + var tests = [ 1.63 + testGetDataStores, 1.64 + testBug924104 1.65 + ]; 1.66 + 1.67 + function runTest() { 1.68 + if (!tests.length) { 1.69 + finish(); 1.70 + return; 1.71 + } 1.72 + 1.73 + var test = tests.shift(); 1.74 + test(); 1.75 + } 1.76 + 1.77 + runTest(); 1.78 + </script> 1.79 +</body> 1.80 +</html>