dom/indexedDB/test/unit/test_remove_index.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 name = this.window ? window.location.pathname : "Splendid Test";
    11   const indexName = "My Test Index";
    13   let request = indexedDB.open(name, 1);
    14   request.onerror = errorHandler;
    15   request.onupgradeneeded = grabEventAndContinueHandler;
    16   let event = yield undefined;
    18   let db = event.target.result;
    19   is(db.objectStoreNames.length, 0, "Correct objectStoreNames list");
    21   let objectStore = db.createObjectStore("test store", { keyPath: "foo" });
    22   is(db.objectStoreNames.length, 1, "Correct objectStoreNames list");
    23   is(db.objectStoreNames.item(0), objectStore.name, "Correct name");
    25   is(objectStore.indexNames.length, 0, "Correct indexNames list");
    27   let index = objectStore.createIndex(indexName, "foo");
    29   is(objectStore.indexNames.length, 1, "Correct indexNames list");
    30   is(objectStore.indexNames.item(0), indexName, "Correct name");
    31   is(objectStore.index(indexName), index, "Correct instance");
    33   objectStore.deleteIndex(indexName);
    35   is(objectStore.indexNames.length, 0, "Correct indexNames list");
    36   try {
    37     objectStore.index(indexName);
    38     ok(false, "should have thrown");
    39   }
    40   catch(ex) {
    41     ok(ex instanceof DOMException, "Got a DOMException");
    42     is(ex.name, "NotFoundError", "expect a NotFoundError");
    43     is(ex.code, DOMException.NOT_FOUND_ERR, "expect a NOT_FOUND_ERR");
    44   }
    46   let index2 = objectStore.createIndex(indexName, "foo");
    47   isnot(index, index2, "New instance should be created");
    49   is(objectStore.indexNames.length, 1, "Correct recreacted indexNames list");
    50   is(objectStore.indexNames.item(0), indexName, "Correct recreacted name");
    51   is(objectStore.index(indexName), index2, "Correct instance");
    53   finishTest();
    54   yield undefined;
    55 }

mercurial