michael@0: /** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: var testGenerator = testSteps(); michael@0: michael@0: function testSteps() michael@0: { michael@0: const name = this.window ? window.location.pathname : "Splendid Test"; michael@0: const objectStore = { name: "Objects", michael@0: options: { keyPath: "id", autoIncrement: true } }; michael@0: michael@0: let request = indexedDB.open(name, 1); michael@0: request.onerror = errorHandler; michael@0: request.onupgradeneeded = grabEventAndContinueHandler; michael@0: let event = yield undefined; michael@0: michael@0: let db1 = event.target.result; michael@0: michael@0: is(db1.objectStoreNames.length, 0, "No objectStores in db1"); michael@0: michael@0: db1.createObjectStore(objectStore.name, objectStore.options); michael@0: michael@0: continueToNextStep(); michael@0: yield undefined; michael@0: michael@0: request = indexedDB.open(name, 1); michael@0: request.onerror = errorHandler; michael@0: request.onsuccess = grabEventAndContinueHandler; michael@0: event = yield undefined; michael@0: michael@0: let db2 = event.target.result; michael@0: michael@0: ok(db1 !== db2, "Databases are not the same object"); michael@0: michael@0: is(db1.objectStoreNames.length, 1, "1 objectStore in db1"); michael@0: is(db1.objectStoreNames.item(0), objectStore.name, "Correct name"); michael@0: michael@0: is(db2.objectStoreNames.length, 1, "1 objectStore in db2"); michael@0: is(db2.objectStoreNames.item(0), objectStore.name, "Correct name"); michael@0: michael@0: let objectStore1 = db1.transaction(objectStore.name) michael@0: .objectStore(objectStore.name); michael@0: is(objectStore1.name, objectStore.name, "Same name"); michael@0: is(objectStore1.keyPath, objectStore.options.keyPath, "Same keyPath"); michael@0: michael@0: let objectStore2 = db2.transaction(objectStore.name) michael@0: .objectStore(objectStore.name); michael@0: michael@0: ok(objectStore1 !== objectStore2, "Different objectStores"); michael@0: is(objectStore1.name, objectStore2.name, "Same name"); michael@0: is(objectStore1.keyPath, objectStore2.keyPath, "Same keyPath"); michael@0: michael@0: finishTest(); michael@0: yield undefined; michael@0: }