diff options
-rw-r--r-- | chrome/test/data/indexeddb/bug_90635.js | 93 | ||||
-rw-r--r-- | chrome/test/data/indexeddb/version_change_crash.js | 122 | ||||
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 2 | ||||
-rwxr-xr-x | chrome/test/functional/indexeddb.py | 47 |
4 files changed, 153 insertions, 111 deletions
diff --git a/chrome/test/data/indexeddb/bug_90635.js b/chrome/test/data/indexeddb/bug_90635.js index dd23299..e52254d 100644 --- a/chrome/test/data/indexeddb/bug_90635.js +++ b/chrome/test/data/indexeddb/bug_90635.js @@ -5,46 +5,75 @@ window.indexedDB = window.indexedDB || window.webkitIndexedDB; window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction; -window.testResult = ''; +function unexpectedErrorCallback() +{ + document.title = 'fail - unexpected error callback'; +} +function unexpectedAbortCallback() +{ + document.title = 'fail - unexpected abort callback'; +} function test() { - var req = window.indexedDB.open('bug90635'); - req.onerror = function(e) { - window.testResult = 'fail'; - }; - req.onsuccess = function(e) { - var db = e.target.result; - var VERSION = '1'; - if (db.version !== VERSION) { - var ver = db.setVersion(VERSION); - ver.onerror = function(e) { - window.testResult = 'fail'; - }; - ver.onsuccess = function(e) { + if (document.location.hash === '#part1') { + testPart1(); + } else if (document.location.hash === '#part2') { + testPart2(); + } else { + document.title = 'fail - no hash'; + } +} + +function testPart1() +{ + var delreq = window.indexedDB.deleteDatabase('bug90635'); + delreq.onerror = unexpectedErrorCallback; + delreq.onsuccess = function() { + var openreq = window.indexedDB.open('bug90635'); + 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'); db.createObjectStore('store2', {keyPath: ''}); db.createObjectStore('store3', {keyPath: 'some_path'}); - test_store(db, 'first run'); + + transaction.onabort = unexpectedAbortCallback; + transaction.oncomplete = function() { + test_store(db, 'first run'); + }; }; - } else { - test_store(db, 'second run'); - } + }; }; +} + +function testPart2() +{ + var openreq = window.indexedDB.open('bug90635'); + openreq.onerror = unexpectedErrorCallback; + openreq.onsuccess = function(e) { + var db = openreq.result; + test_store(db, 'second run'); + }; +} + +function test_store(db, msg) { + var transaction = db.transaction(['store1', 'store2', 'store3'], + IDBTransaction.READ_ONLY); + var store1 = transaction.objectStore('store1'); + var store2 = transaction.objectStore('store2'); + var store3 = transaction.objectStore('store3'); - function test_store(db, msg) { - var transaction = db.transaction(['store1', 'store2', 'store3'], - IDBTransaction.READ_ONLY); - var store1 = transaction.objectStore('store1'); - var store2 = transaction.objectStore('store2'); - var store3 = transaction.objectStore('store3'); - - if (store1.keyPath !== null || - store2.keyPath !== '' || - store3.keyPath !== 'some_path') { - window.testResult = 'fail - ' + msg; - } else { - window.testResult = 'pass - ' + msg; - } + if (store1.keyPath !== null || + store2.keyPath !== '' || + store3.keyPath !== 'some_path') { + document.title = 'fail - ' + msg; + } else { + document.title = 'pass - ' + msg; } } diff --git a/chrome/test/data/indexeddb/version_change_crash.js b/chrome/test/data/indexeddb/version_change_crash.js index 97e8b01..c74846b 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'; + }; } diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index 634d139..5a8b971 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -85,8 +85,6 @@ '-autofill.AutofillTest.testFillProfileCrazyCharacters', # crbug.com/99475 '-autofill.AutofillTest.testNoDuplicatePhoneNumsInPrefs', - # crbug.com/103456 - '-indexeddb.IndexedDBTest.testVersionChangeCrashResilience', # crbug.com/99506 '-notifications.NotificationsTest.testSpecialURLNotification', # crbug.com/71715 diff --git a/chrome/test/functional/indexeddb.py b/chrome/test/functional/indexeddb.py index cb8d371..5e4e560 100755 --- a/chrome/test/functional/indexeddb.py +++ b/chrome/test/functional/indexeddb.py @@ -15,36 +15,21 @@ class IndexedDBTest(pyauto.PyUITest): crash_url = 'about:inducebrowsercrashforrealz' self.NavigateToURL(crash_url) - def _GetTestResult(self): - """Returns the result of an asynchronous test""" - js = """ - window.domAutomationController.send(window.testResult); - """ - return self.ExecuteJavascript(js) - - def _WaitForTestResult(self): - """Waits until a non-empty asynchronous test result is recorded""" - self.assertTrue(self.WaitUntil(lambda: self._GetTestResult() != '', - timeout=120), - msg='Test did not finish') - def testIndexedDBNullKeyPathPersistence(self): """Verify null key path persists after restarting browser.""" url = self.GetHttpURLForDataPath('indexeddb', 'bug_90635.html') - self.NavigateToURL(url) - self._WaitForTestResult() - self.assertEqual(self._GetTestResult(), - 'pass - first run', - msg='Key paths had unexpected values') + self.NavigateToURL(url + '#part1') + self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, + expect_retval='pass - first run'), + msg='Key paths had unexpected values') self.RestartBrowser(clear_profile=False) - self.NavigateToURL(url) - self._WaitForTestResult() - self.assertEqual(self._GetTestResult(), - 'pass - second run', + self.NavigateToURL(url + '#part2') + self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, + expect_retval='pass - second run'), msg='Key paths had unexpected values') def testVersionChangeCrashResilience(self): @@ -54,23 +39,25 @@ class IndexedDBTest(pyauto.PyUITest): url = self.GetHttpURLForDataPath('indexeddb', 'version_change_crash.html') self.NavigateToURL(url + '#part1') - self.assertTrue(self.WaitUntil( - lambda: self._GetTestResult() == 'part1 - complete')) + self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, + expect_retval='pass - part1 - complete'), + msg='Failed to prepare database') self.RestartBrowser(clear_profile=False) self.NavigateToURL(url + '#part2') - self.assertTrue(self.WaitUntil( - lambda: self._GetTestResult() != 'part2 - crash me')) + self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, + expect_retval='pass - part2 - crash me'), + msg='Failed to start transaction') + self._CrashBrowser() self.RestartBrowser(clear_profile=False) self.NavigateToURL(url + '#part3') - self._WaitForTestResult() - self.assertEqual(self._GetTestResult(), - 'part3 - pass', - msg='VERSION_CHANGE not completely aborted') + self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, + expect_retval='pass - part3 - rolled back'), + msg='VERSION_CHANGE not completely aborted') if __name__ == '__main__': pyauto_functional.Main() |