| Index: chrome/test/data/indexeddb/version_change_crash.js
|
| diff --git a/chrome/test/data/indexeddb/version_change_crash.js b/chrome/test/data/indexeddb/version_change_crash.js
|
| index 97e8b01f1155569dd81c882c28eb405f0c77d1af..c74846be40edbe640d36f8daccce8d1a8f59b924 100644
|
| --- a/chrome/test/data/indexeddb/version_change_crash.js
|
| +++ b/chrome/test/data/indexeddb/version_change_crash.js
|
| @@ -7,75 +7,103 @@ window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
|
|
|
| window.testResult = '';
|
|
|
| -var INDUCE_BROWSER_CRASH_URL = 'about:inducebrowsercrashforrealz';
|
| -function crashBrowser() {
|
| - chrome.tabs.create({url: INDUCE_BROWSER_CRASH_URL}, callbackFail(ERROR));
|
| +function unexpectedErrorCallback()
|
| +{
|
| + document.title = 'fail - unexpected error callback';
|
| +}
|
| +function unexpectedAbortCallback()
|
| +{
|
| + document.title = 'fail - unexpected abort callback';
|
| +}
|
| +function unexpectedCompleteCallback()
|
| +{
|
| + document.title = 'fail - unexpected complete callback';
|
| }
|
| -
|
|
|
| function test() {
|
| -
|
| - var openreq = window.indexedDB.open('test-db');
|
| - openreq.onsuccess = function(e) {
|
| - var db = openreq.result;
|
| -
|
| - if (document.location.hash === '#part1') {
|
| - testPart1(db);
|
| - } else if (document.location.hash === '#part2') {
|
| - testPart2(db);
|
| - } else if (document.location.hash === '#part3') {
|
| - testPart3(db);
|
| - } else {
|
| - window.testResult = 'fail';
|
| - }
|
| - };
|
| + if (document.location.hash === '#part1') {
|
| + testPart1();
|
| + } else if (document.location.hash === '#part2') {
|
| + testPart2();
|
| + } else if (document.location.hash === '#part3') {
|
| + testPart3();
|
| + } else {
|
| + document.title = 'fail';
|
| + }
|
| }
|
|
|
| -function testPart1(db) {
|
| +function testPart1() {
|
| // Prepare the database, then exit normally
|
|
|
| // Set version 1, create store1
|
| - var setverreq = db.setVersion('1.0');
|
| - setverreq.onsuccess = function(e) {
|
| - db.createObjectStore('store1');
|
| - setverreq.result.oncomplete = function (e) {
|
| - window.testResult = 'part1 - complete';
|
| + var delreq = window.indexedDB.deleteDatabase('version-change-crash');
|
| + delreq.onerror = unexpectedErrorCallback;
|
| + delreq.onsuccess = function() {
|
| + var openreq = window.indexedDB.open('version-change-crash');
|
| + openreq.onerror = unexpectedErrorCallback;
|
| + openreq.onsuccess = function(e) {
|
| + var db = openreq.result;
|
| + var setverreq = db.setVersion('1');
|
| + setverreq.onerror = unexpectedErrorCallback;
|
| + setverreq.onsuccess = function(e) {
|
| + var transaction = setverreq.result;
|
| + db.createObjectStore('store1');
|
| + transaction.onabort = unexpectedAbortCallback;
|
| + transaction.oncomplete = function (e) {
|
| + document.title = 'pass - part1 - complete';
|
| + };
|
| + };
|
| };
|
| };
|
| }
|
|
|
| -function testPart2(db) {
|
| +function testPart2() {
|
| // Start a VERSION_CHANGE then crash
|
|
|
| // Set version 2, twiddle stores and crash
|
| - var setverreq = db.setVersion('2.0');
|
| - setverreq.onsuccess = function(e) {
|
| - var store = db.createObjectStore('store2');
|
| - window.testResult = 'part2 - crash me';
|
| -
|
| - // Keep adding to the transaction so it can't commit
|
| - (function loop() { store.put(0, 0).onsuccess = loop; }());
|
| + var openreq = window.indexedDB.open('version-change-crash');
|
| + openreq.onerror = unexpectedErrorCallback;
|
| + openreq.onsuccess = function(e) {
|
| + var db = openreq.result;
|
| + var setverreq = db.setVersion('2');
|
| + setverreq.onerror = unexpectedErrorCallback;
|
| + setverreq.onsuccess = function(e) {
|
| + var transaction = setverreq.result;
|
| + transaction.onabort = unexpectedAbortCallback;
|
| + transaction.oncomplete = unexpectedCompleteCallback;
|
| +
|
| + var store = db.createObjectStore('store2');
|
| + document.title = 'pass - part2 - crash me';
|
| +
|
| + // Keep adding to the transaction so it can't commit
|
| + (function loop() { store.put(0, 0).onsuccess = loop; }());
|
| + };
|
| };
|
| }
|
|
|
| -function testPart3(db) {
|
| +function testPart3() {
|
| // Validate that Part 2 never committed
|
|
|
| // Check version
|
| - if (db.version !== '1.0') {
|
| - window.testResult = 'fail, version incorrect';
|
| - return;
|
| - }
|
| + var openreq = window.indexedDB.open('version-change-crash');
|
| + openreq.onerror = unexpectedErrorCallback;
|
| + openreq.onsuccess = function(e) {
|
| + var db = openreq.result;
|
| + if (db.version !== '1') {
|
| + document.title = 'fail - version incorrect';
|
| + return;
|
| + }
|
|
|
| - if (!db.objectStoreNames.contains('store1')) {
|
| - window.testResult = 'fail, store1 does not exist';
|
| - return;
|
| - }
|
| + if (!db.objectStoreNames.contains('store1')) {
|
| + document.title = 'fail - store1 does not exist';
|
| + return;
|
| + }
|
|
|
| - if (db.objectStoreNames.contains('store2')) {
|
| - window.testResult = 'fail, store2 exists';
|
| - return;
|
| - }
|
| + if (db.objectStoreNames.contains('store2')) {
|
| + document.title = 'fail - store2 exists';
|
| + return;
|
| + }
|
|
|
| - window.testResult = 'part3 - pass';
|
| + document.title = 'pass - part3 - rolled back';
|
| + };
|
| }
|
|
|