| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 function test() | |
| 6 { | |
| 7 if (document.location.hash === '#part1') { | |
| 8 testPart1(); | |
| 9 } else if (document.location.hash === '#part2') { | |
| 10 testPart2(); | |
| 11 } else { | |
| 12 result('fail - unexpected hash'); | |
| 13 } | |
| 14 } | |
| 15 | |
| 16 function testPart1() | |
| 17 { | |
| 18 var delreq = window.indexedDB.deleteDatabase('bug90635'); | |
| 19 delreq.onerror = unexpectedErrorCallback; | |
| 20 delreq.onsuccess = function() { | |
| 21 var openreq = window.indexedDB.open('bug90635'); | |
| 22 openreq.onerror = unexpectedErrorCallback; | |
| 23 openreq.onsuccess = function(e) { | |
| 24 var db = openreq.result; | |
| 25 var setverreq = db.setVersion('1'); | |
| 26 setverreq.onerror = unexpectedErrorCallback; | |
| 27 setverreq.onsuccess = function(e) { | |
| 28 var transaction = setverreq.result; | |
| 29 | |
| 30 db.createObjectStore('store1'); | |
| 31 db.createObjectStore('store2', {keyPath: ''}); | |
| 32 db.createObjectStore('store3', {keyPath: 'some_path'}); | |
| 33 | |
| 34 transaction.onabort = unexpectedAbortCallback; | |
| 35 transaction.oncomplete = function() { | |
| 36 test_store(db, 'first run'); | |
| 37 }; | |
| 38 }; | |
| 39 }; | |
| 40 }; | |
| 41 } | |
| 42 | |
| 43 function testPart2() | |
| 44 { | |
| 45 var openreq = window.indexedDB.open('bug90635'); | |
| 46 openreq.onerror = unexpectedErrorCallback; | |
| 47 openreq.onsuccess = function(e) { | |
| 48 var db = openreq.result; | |
| 49 test_store(db, 'second run'); | |
| 50 }; | |
| 51 } | |
| 52 | |
| 53 function test_store(db, msg) { | |
| 54 var transaction = db.transaction(['store1', 'store2', 'store3'], 'readonly'); | |
| 55 var store1 = transaction.objectStore('store1'); | |
| 56 var store2 = transaction.objectStore('store2'); | |
| 57 var store3 = transaction.objectStore('store3'); | |
| 58 | |
| 59 if (store1.keyPath !== null || | |
| 60 store2.keyPath !== '' || | |
| 61 store3.keyPath !== 'some_path') { | |
| 62 result('fail - ' + msg); | |
| 63 } else { | |
| 64 result('pass - ' + msg); | |
| 65 } | |
| 66 } | |
| OLD | NEW |