Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /** |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | var testGenerator = testSteps(); |
michael@0 | 7 | |
michael@0 | 8 | function testSteps() |
michael@0 | 9 | { |
michael@0 | 10 | const name = this.window ? window.location.pathname : "Splendid Test"; |
michael@0 | 11 | const objectStore = { name: "Objects", |
michael@0 | 12 | options: { keyPath: "id", autoIncrement: true } }; |
michael@0 | 13 | |
michael@0 | 14 | let request = indexedDB.open(name, 1); |
michael@0 | 15 | request.onerror = errorHandler; |
michael@0 | 16 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 17 | let event = yield undefined; |
michael@0 | 18 | |
michael@0 | 19 | let db1 = event.target.result; |
michael@0 | 20 | |
michael@0 | 21 | is(db1.objectStoreNames.length, 0, "No objectStores in db1"); |
michael@0 | 22 | |
michael@0 | 23 | db1.createObjectStore(objectStore.name, objectStore.options); |
michael@0 | 24 | |
michael@0 | 25 | continueToNextStep(); |
michael@0 | 26 | yield undefined; |
michael@0 | 27 | |
michael@0 | 28 | request = indexedDB.open(name, 1); |
michael@0 | 29 | request.onerror = errorHandler; |
michael@0 | 30 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 31 | event = yield undefined; |
michael@0 | 32 | |
michael@0 | 33 | let db2 = event.target.result; |
michael@0 | 34 | |
michael@0 | 35 | ok(db1 !== db2, "Databases are not the same object"); |
michael@0 | 36 | |
michael@0 | 37 | is(db1.objectStoreNames.length, 1, "1 objectStore in db1"); |
michael@0 | 38 | is(db1.objectStoreNames.item(0), objectStore.name, "Correct name"); |
michael@0 | 39 | |
michael@0 | 40 | is(db2.objectStoreNames.length, 1, "1 objectStore in db2"); |
michael@0 | 41 | is(db2.objectStoreNames.item(0), objectStore.name, "Correct name"); |
michael@0 | 42 | |
michael@0 | 43 | let objectStore1 = db1.transaction(objectStore.name) |
michael@0 | 44 | .objectStore(objectStore.name); |
michael@0 | 45 | is(objectStore1.name, objectStore.name, "Same name"); |
michael@0 | 46 | is(objectStore1.keyPath, objectStore.options.keyPath, "Same keyPath"); |
michael@0 | 47 | |
michael@0 | 48 | let objectStore2 = db2.transaction(objectStore.name) |
michael@0 | 49 | .objectStore(objectStore.name); |
michael@0 | 50 | |
michael@0 | 51 | ok(objectStore1 !== objectStore2, "Different objectStores"); |
michael@0 | 52 | is(objectStore1.name, objectStore2.name, "Same name"); |
michael@0 | 53 | is(objectStore1.keyPath, objectStore2.keyPath, "Same keyPath"); |
michael@0 | 54 | |
michael@0 | 55 | finishTest(); |
michael@0 | 56 | yield undefined; |
michael@0 | 57 | } |