IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / test / data / indexeddb / bug_90635.js
blobe59d54feb42cd7e1f39d39dbdf7500d69384a07c
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.
5 function test()
7 if (document.location.hash === '#part1') {
8 testPart1();
9 } else if (document.location.hash === '#part2') {
10 testPart2();
11 } else {
12 result('fail - unexpected hash');
16 function testPart1()
18 var delreq = window.indexedDB.deleteDatabase('bug90635');
19 delreq.onerror = unexpectedErrorCallback;
20 delreq.onsuccess = function() {
21 var openreq = window.indexedDB.open('bug90635', 1);
22 openreq.onerror = unexpectedErrorCallback;
23 openreq.onblocked = unexpectedBlockedCallback;
24 openreq.onupgradeneeded = function(e) {
25 db = openreq.result;
26 var transaction = openreq.transaction;
27 transaction.onabort = unexpectedAbortCallback;
29 db.createObjectStore('store1');
30 db.createObjectStore('store2', {keyPath: ''});
31 db.createObjectStore('store3', {keyPath: 'some_path'});
33 openreq.onsuccess = function() {
34 test_store(db, 'first run');
39 function testPart2()
41 var openreq = window.indexedDB.open('bug90635');
42 openreq.onerror = unexpectedErrorCallback;
43 openreq.onsuccess = function(e) {
44 var db = openreq.result;
45 test_store(db, 'second run');
49 function test_store(db, msg) {
50 var transaction = db.transaction(['store1', 'store2', 'store3'], 'readonly');
51 var store1 = transaction.objectStore('store1');
52 var store2 = transaction.objectStore('store2');
53 var store3 = transaction.objectStore('store3');
55 if (store1.keyPath !== null ||
56 store2.keyPath !== '' ||
57 store3.keyPath !== 'some_path') {
58 result('fail - ' + msg);
59 } else {
60 result('pass - ' + msg);