1 <html> 2 <head> 3 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> 4 <script src="../../fast/js/resources/js-test-pre.js"></script> 5 <script src="../../fast/js/resources/js-test-post-function.js"></script> 6 <script src="resources/shared.js"></script> 7 </head> 8 <body> 9 <p id="description"></p> 10 <div id="console"></div> 11 <script> 12 13 description("An open connection blocks a separate connection's setVersion call"); 14 if (window.layoutTestController) 15 layoutTestController.waitUntilDone(); 16 17 connections = [] 18 function test() 19 { 20 if ('webkitIndexedDB' in window) 21 IndexedDB = webkitIndexedDB; 22 else if ('mozIndexedDB' in window) 23 IndexedDB = mozIndexedDB; 24 shouldBeFalse("IndexedDB == null"); 25 openDBConnection(); 26 } 27 28 function openDBConnection() 29 { 30 request = evalAndLog("IndexedDB.open('set-version-blocked')"); 31 request.onsuccess = openSuccess; 32 request.onerror = unexpectedErrorCallback; 33 } 34 35 function openSuccess() 36 { 37 connection = event.target.result; 38 connections.push(connection); 39 original_version = connection.version; 40 if (connections.length < 2) 41 openDBConnection(); 42 else { 43 var versionChangeRequest = evalAndLog("connections[0].setVersion('version 1')"); 44 versionChangeRequest.onerror = unexpectedErrorCallback; 45 versionChangeRequest.onsuccess = inSetVersion; 46 versionChangeRequest.onblocked = blocked; 47 } 48 } 49 50 seen_blocked_event = false; 51 function blocked() 52 { 53 evalAndLog("seen_blocked_event = true"); 54 blocked_event = event; 55 shouldBeEqualToString("blocked_event.version", "version 1"); 56 shouldEvaluateTo("blocked_event.target.readyState", 1); 57 evalAndLog("connections[1].close()"); 58 } 59 60 function inSetVersion() 61 { 62 debug("in setVersion.onsuccess"); 63 shouldBeTrue("seen_blocked_event"); 64 deleteAllObjectStores(connections[0]); 65 done(); 66 } 67 68 var successfullyParsed = true; 69 70 test(); 71 72 </script> 73 </body> 74 </html> 75