1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/datastore/tests/file_bug976311.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <meta charset="utf-8"> 1.8 + <title>Test for DataStore - bug 976311 app1</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 + var gStores = []; 1.19 + var expectedWhere; 1.20 + 1.21 + function is(a, b, msg) { 1.22 + ok(a === b, msg); 1.23 + } 1.24 + 1.25 + function ok(a, msg) { 1.26 + alert((a ? 'OK' : 'KO')+ ' ' + msg) 1.27 + } 1.28 + 1.29 + function cbError() { 1.30 + alert('KO error'); 1.31 + } 1.32 + 1.33 + function finish() { 1.34 + alert('DONE'); 1.35 + } 1.36 + 1.37 + function checkEvent(id) { 1.38 + is(expectedWhere, id, "Message on the correct DS: " + id + " " + expectedWhere); 1.39 + runTest(); 1.40 + } 1.41 + 1.42 + function testGetDataStores() { 1.43 + navigator.getDataStores('foo').then(function(stores) { 1.44 + is(stores.length, 2, "getDataStores('foo') returns 1 element"); 1.45 + 1.46 + is(stores[0].name, 'foo', 'The dataStore.name is foo'); 1.47 + is(stores[0].readOnly, false, 'The dataStore foo is not in readonly'); 1.48 + stores[0].onchange = function(evt) { checkEvent(0); } 1.49 + gStores.push(stores[0]); 1.50 + 1.51 + is(stores[1].name, 'foo', 'The dataStore.name is foo'); 1.52 + is(stores[1].readOnly, false, 'The dataStore foo is not in readonly'); 1.53 + stores[1].onchange = function(evt) { checkEvent(1); } 1.54 + gStores.push(stores[1]); 1.55 + 1.56 + runTest(); 1.57 + }, cbError); 1.58 + } 1.59 + 1.60 + function testStoreAdd(where, value) { 1.61 + expectedWhere = where; 1.62 + dump("ADD TO: " + gStores[where].owner + "\n"); 1.63 + gStores[where].add({ a: value }); 1.64 + } 1.65 + 1.66 + var tests = [ 1.67 + // Test for GetDataStore 1.68 + testGetDataStores, 1.69 + 1.70 + function() { testStoreAdd(0, 1); }, 1.71 + function() { testStoreAdd(1, 2); }, 1.72 + function() { testStoreAdd(0, 3); }, 1.73 + function() { testStoreAdd(1, 4); } 1.74 + ]; 1.75 + 1.76 + function runTest() { 1.77 + if (!tests.length) { 1.78 + finish(); 1.79 + return; 1.80 + } 1.81 + 1.82 + var test = tests.shift(); 1.83 + test(); 1.84 + } 1.85 + 1.86 + runTest(); 1.87 + </script> 1.88 +</pre> 1.89 +</body> 1.90 +</html> 1.91 +