dom/indexedDB/test/unit/test_cursor_cycle.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /**
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/publicdomain/zero/1.0/
     4  */
     6 var testGenerator = testSteps();
     8 function testSteps()
     9 {
    10   const Bob = { ss: "237-23-7732", name: "Bob" };
    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;
    17   let db = event.target.result;
    18   event.target.onsuccess = continueToNextStep;
    20   let objectStore = db.createObjectStore("foo", { keyPath: "ss" });
    21   objectStore.createIndex("name", "name", { unique: true });
    22   objectStore.add(Bob);
    23   yield undefined;
    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();
    38   objectStore = null; // Bug 943409 workaround.
    40   yield undefined;
    41 }

mercurial