summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/test/data/indexeddb/version_change_blocked.html10
-rw-r--r--chrome/test/data/indexeddb/version_change_blocked.js69
-rwxr-xr-xchrome/test/functional/indexeddb.py24
3 files changed, 102 insertions, 1 deletions
diff --git a/chrome/test/data/indexeddb/version_change_blocked.html b/chrome/test/data/indexeddb/version_change_blocked.html
new file mode 100644
index 0000000..95b6977
--- /dev/null
+++ b/chrome/test/data/indexeddb/version_change_blocked.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>IndexedDB regression test for bug 80111</title>
+ <script type="text/javascript" src="version_change_blocked.js"></script>
+ </head>
+ <body onLoad="test()">
+ <div id="status">Starting...</div>
+ </body>
+</html>
+
diff --git a/chrome/test/data/indexeddb/version_change_blocked.js b/chrome/test/data/indexeddb/version_change_blocked.js
new file mode 100644
index 0000000..b556bd3
--- /dev/null
+++ b/chrome/test/data/indexeddb/version_change_blocked.js
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+window.indexedDB = window.indexedDB || window.webkitIndexedDB;
+
+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() {
+ if (document.location.hash === '#tab1') {
+ prepareDatabase(0, function () { doSetVersion(1); });
+ } else if (document.location.hash === '#tab2') {
+ doSetVersion(2);
+ } else {
+ document.title = 'fail';
+ }
+}
+
+function prepareDatabase(version, callback) {
+ // Prepare the database, then exit normally
+
+ var delreq = window.indexedDB.deleteDatabase('version-change-blocked');
+ delreq.onerror = unexpectedErrorCallback;
+ delreq.onsuccess = function() {
+ var openreq = window.indexedDB.open('version-change-blocked');
+ openreq.onerror = unexpectedErrorCallback;
+ openreq.onsuccess = function(e) {
+ var db = openreq.result;
+ var setverreq = db.setVersion(String(version));
+ setverreq.onerror = unexpectedErrorCallback;
+ setverreq.onsuccess = function(e) {
+ var transaction = setverreq.result;
+ transaction.onabort = unexpectedAbortCallback;
+ transaction.oncomplete = function (e) {
+ db.close();
+ callback();
+ };
+ };
+ };
+ };
+}
+
+function doSetVersion(version) {
+ // Open the database and try a setVersion
+ var openreq = window.indexedDB.open('version-change-blocked');
+ openreq.onerror = unexpectedErrorCallback;
+ openreq.onsuccess = function(e) {
+ window.db = openreq.result;
+ var setverreq = window.db.setVersion(String(version));
+ setverreq.onerror = unexpectedErrorCallback;
+ setverreq.onblocked = function(e) {
+ document.title = 'setVersion(' + version + ') blocked';
+ };
+ setverreq.onsuccess = function(e) {
+ document.title = 'setVersion(' + version + ') complete';
+ };
+ };
+}
diff --git a/chrome/test/functional/indexeddb.py b/chrome/test/functional/indexeddb.py
index 5e4e560..162aa9d 100755
--- a/chrome/test/functional/indexeddb.py
+++ b/chrome/test/functional/indexeddb.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -59,5 +59,27 @@ class IndexedDBTest(pyauto.PyUITest):
expect_retval='pass - part3 - rolled back'),
msg='VERSION_CHANGE not completely aborted')
+ def testConnectionsClosedOnTabClose(self):
+ """Verify that open DB connections are closed when a tab is destroyed."""
+
+ url = self.GetHttpURLForDataPath('indexeddb', 'version_change_blocked.html')
+
+ self.NavigateToURL(url + '#tab1')
+ pid = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid']
+ self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
+ expect_retval='setVersion(1) complete'),
+ msg='Version change failed')
+
+ # Start to a different URL to force a new renderer process
+ self.AppendTab(pyauto.GURL('about:blank'))
+ self.NavigateToURL(url + '#tab2')
+ self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
+ expect_retval='setVersion(2) blocked'),
+ msg='Version change not blocked as expected')
+ self.KillRendererProcess(pid)
+ self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
+ expect_retval='setVersion(2) complete'),
+ msg='Version change never unblocked')
+
if __name__ == '__main__':
pyauto_functional.Main()