dom/indexedDB/test/unit/test_cursor_cycle.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/test/unit/test_cursor_cycle.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/**
     1.5 + * Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.7 + */
     1.8 +
     1.9 +var testGenerator = testSteps();
    1.10 +
    1.11 +function testSteps()
    1.12 +{
    1.13 +  const Bob = { ss: "237-23-7732", name: "Bob" };
    1.14 +
    1.15 +  let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1);
    1.16 +  request.onerror = errorHandler;
    1.17 +  request.onupgradeneeded = grabEventAndContinueHandler;
    1.18 +  let event = yield undefined;
    1.19 +
    1.20 +  let db = event.target.result;
    1.21 +  event.target.onsuccess = continueToNextStep;
    1.22 +
    1.23 +  let objectStore = db.createObjectStore("foo", { keyPath: "ss" });
    1.24 +  objectStore.createIndex("name", "name", { unique: true });
    1.25 +  objectStore.add(Bob);
    1.26 +  yield undefined;
    1.27 +
    1.28 +  db.transaction("foo", "readwrite").objectStore("foo")
    1.29 +    .index("name").openCursor().onsuccess = function(event) {
    1.30 +    event.target.transaction.oncomplete = continueToNextStep;
    1.31 +    let cursor = event.target.result;
    1.32 +    if (cursor) {
    1.33 +      let objectStore = event.target.transaction.objectStore("foo");
    1.34 +      objectStore.delete(Bob.ss)
    1.35 +                 .onsuccess = function(event) { cursor.continue(); };
    1.36 +    }
    1.37 +  };
    1.38 +  yield undefined;
    1.39 +  finishTest();
    1.40 +
    1.41 +  objectStore = null; // Bug 943409 workaround.
    1.42 +
    1.43 +  yield undefined;
    1.44 +}

mercurial