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 | let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1); |
michael@0 | 11 | request.onerror = errorHandler; |
michael@0 | 12 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 13 | let event = yield undefined; |
michael@0 | 14 | |
michael@0 | 15 | let db = event.target.result; |
michael@0 | 16 | let transaction = event.target.transaction; |
michael@0 | 17 | |
michael@0 | 18 | let objectStore1 = db.createObjectStore("foo"); |
michael@0 | 19 | let objectStore2 = transaction.objectStore("foo"); |
michael@0 | 20 | ok(objectStore1 === objectStore2, "Got same objectStores"); |
michael@0 | 21 | |
michael@0 | 22 | let index1 = objectStore1.createIndex("bar", "key"); |
michael@0 | 23 | let index2 = objectStore2.index("bar"); |
michael@0 | 24 | ok(index1 === index2, "Got same indexes"); |
michael@0 | 25 | |
michael@0 | 26 | request.onsuccess = continueToNextStep; |
michael@0 | 27 | yield undefined; |
michael@0 | 28 | |
michael@0 | 29 | transaction = db.transaction(db.objectStoreNames); |
michael@0 | 30 | |
michael@0 | 31 | let objectStore3 = transaction.objectStore("foo"); |
michael@0 | 32 | let objectStore4 = transaction.objectStore("foo"); |
michael@0 | 33 | ok(objectStore3 === objectStore4, "Got same objectStores"); |
michael@0 | 34 | |
michael@0 | 35 | ok(objectStore3 !== objectStore1, "Different objectStores"); |
michael@0 | 36 | ok(objectStore4 !== objectStore2, "Different objectStores"); |
michael@0 | 37 | |
michael@0 | 38 | let index3 = objectStore3.index("bar"); |
michael@0 | 39 | let index4 = objectStore4.index("bar"); |
michael@0 | 40 | ok(index3 === index4, "Got same indexes"); |
michael@0 | 41 | |
michael@0 | 42 | ok(index3 !== index1, "Different indexes"); |
michael@0 | 43 | ok(index4 !== index2, "Different indexes"); |
michael@0 | 44 | |
michael@0 | 45 | finishTest(); |
michael@0 | 46 | yield undefined; |
michael@0 | 47 | } |
michael@0 | 48 |