|
1 /** |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 var testGenerator = testSteps(); |
|
7 |
|
8 function testSteps() |
|
9 { |
|
10 let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1); |
|
11 request.onerror = errorHandler; |
|
12 request.onupgradeneeded = grabEventAndContinueHandler; |
|
13 let event = yield undefined; |
|
14 |
|
15 let db = event.target.result; |
|
16 let transaction = event.target.transaction; |
|
17 |
|
18 let objectStore1 = db.createObjectStore("foo"); |
|
19 let objectStore2 = transaction.objectStore("foo"); |
|
20 ok(objectStore1 === objectStore2, "Got same objectStores"); |
|
21 |
|
22 let index1 = objectStore1.createIndex("bar", "key"); |
|
23 let index2 = objectStore2.index("bar"); |
|
24 ok(index1 === index2, "Got same indexes"); |
|
25 |
|
26 request.onsuccess = continueToNextStep; |
|
27 yield undefined; |
|
28 |
|
29 transaction = db.transaction(db.objectStoreNames); |
|
30 |
|
31 let objectStore3 = transaction.objectStore("foo"); |
|
32 let objectStore4 = transaction.objectStore("foo"); |
|
33 ok(objectStore3 === objectStore4, "Got same objectStores"); |
|
34 |
|
35 ok(objectStore3 !== objectStore1, "Different objectStores"); |
|
36 ok(objectStore4 !== objectStore2, "Different objectStores"); |
|
37 |
|
38 let index3 = objectStore3.index("bar"); |
|
39 let index4 = objectStore4.index("bar"); |
|
40 ok(index3 === index4, "Got same indexes"); |
|
41 |
|
42 ok(index3 !== index1, "Different indexes"); |
|
43 ok(index4 !== index2, "Different indexes"); |
|
44 |
|
45 finishTest(); |
|
46 yield undefined; |
|
47 } |
|
48 |