1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 if (document.location.hash === '#tab1') {
8 prepareDatabase(function () { doSetVersion(2); });
9 } else if (document.location.hash === '#tab2') {
12 result('fail - unexpected hash');
16 function prepareDatabase(callback)
18 // Prepare the database, then exit normally
19 var delreq = window.indexedDB.deleteDatabase('version-change-blocked');
20 delreq.onerror = unexpectedErrorCallback;
21 delreq.onsuccess = function() {
26 function reOpen(callback)
28 request = indexedDB.open('version-change-blocked');
29 request.onerror = unexpectedErrorCallback;
30 request.onblocked = unexpectedBlockedCallback;
31 request.onupgradeneeded = function() {
32 db = event.target.result;
33 db.createObjectStore("someobjectstore");
35 request.onsuccess = function() {
41 function doSetVersion(version)
43 // Open the database and try a setVersion
44 var openreq = window.indexedDB.open('version-change-blocked', version);
45 openreq.onerror = unexpectedErrorCallback;
46 var upgradeneededComplete = false;
47 openreq.onblocked = function(e) {
48 result('setVersion(' + version + ') blocked');
50 openreq.onupgradeneeded = function(e) {
51 openreq.transaction.oncomplete = function(e2) {
52 result('setVersion(' + version + ') complete');