|
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 const Bob = { ss: "237-23-7732", name: "Bob" }; |
|
11 |
|
12 let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1); |
|
13 request.onerror = errorHandler; |
|
14 request.onupgradeneeded = grabEventAndContinueHandler; |
|
15 let event = yield undefined; |
|
16 |
|
17 let db = event.target.result; |
|
18 event.target.onsuccess = continueToNextStep; |
|
19 |
|
20 let objectStore = db.createObjectStore("foo", { keyPath: "ss" }); |
|
21 objectStore.createIndex("name", "name", { unique: true }); |
|
22 objectStore.add(Bob); |
|
23 yield undefined; |
|
24 |
|
25 db.transaction("foo", "readwrite").objectStore("foo") |
|
26 .index("name").openCursor().onsuccess = function(event) { |
|
27 event.target.transaction.oncomplete = continueToNextStep; |
|
28 let cursor = event.target.result; |
|
29 if (cursor) { |
|
30 let objectStore = event.target.transaction.objectStore("foo"); |
|
31 objectStore.delete(Bob.ss) |
|
32 .onsuccess = function(event) { cursor.continue(); }; |
|
33 } |
|
34 }; |
|
35 yield undefined; |
|
36 finishTest(); |
|
37 |
|
38 objectStore = null; // Bug 943409 workaround. |
|
39 |
|
40 yield undefined; |
|
41 } |