Bug 1816170 - Disable perftest-on-autoland cron. r=aglavic
[gecko.git] / dom / indexedDB / test / unit / test_cursor_cycle.js
blobe7a93a2d93b0c57349b19fbe7f6f27f46183f5b8
1 /**
2  * Any copyright is dedicated to the Public Domain.
3  * http://creativecommons.org/publicdomain/zero/1.0/
4  */
6 /* exported testGenerator */
7 var testGenerator = testSteps();
9 function* testSteps() {
10   const Bob = { ss: "237-23-7732", name: "Bob" };
12   let request = indexedDB.open(
13     this.window ? window.location.pathname : "Splendid Test",
14     1
15   );
16   request.onerror = errorHandler;
17   request.onupgradeneeded = grabEventAndContinueHandler;
18   let event = yield undefined;
20   let db = event.target.result;
21   event.target.onsuccess = continueToNextStep;
23   let objectStore = db.createObjectStore("foo", { keyPath: "ss" });
24   objectStore.createIndex("name", "name", { unique: true });
25   objectStore.add(Bob);
26   yield undefined;
28   db
29     .transaction("foo", "readwrite")
30     .objectStore("foo")
31     .index("name")
32     .openCursor().onsuccess = function(event) {
33     event.target.transaction.oncomplete = continueToNextStep;
34     let cursor = event.target.result;
35     if (cursor) {
36       let objectStore = event.target.transaction.objectStore("foo");
37       objectStore.delete(Bob.ss).onsuccess = function(event) {
38         cursor.continue();
39       };
40     }
41   };
42   yield undefined;
43   finishTest();
45   objectStore = null; // Bug 943409 workaround.
47   yield undefined;