dom/indexedDB/test/unit/test_open_objectStore.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/test/unit/test_open_objectStore.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     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 name = this.window ? window.location.pathname : "Splendid Test";
    1.14 +  const objectStoreName = "Objects";
    1.15 +
    1.16 +  let request = indexedDB.open(name, 1);
    1.17 +  request.onerror = errorHandler;
    1.18 +  request.onupgradeneeded = grabEventAndContinueHandler;
    1.19 +  request.onsuccess = grabEventAndContinueHandler;
    1.20 +  let event = yield undefined;
    1.21 +
    1.22 +  let db = event.target.result;
    1.23 +  is(db.objectStoreNames.length, 0, "Bad objectStores list");
    1.24 +
    1.25 +  let objectStore = db.createObjectStore(objectStoreName,
    1.26 +                                         { keyPath: "foo" });
    1.27 +
    1.28 +  is(db.objectStoreNames.length, 1, "Bad objectStores list");
    1.29 +  is(db.objectStoreNames.item(0), objectStoreName, "Bad name");
    1.30 +
    1.31 +  yield undefined;
    1.32 +
    1.33 +  objectStore = db.transaction(objectStoreName).objectStore(objectStoreName);
    1.34 +
    1.35 +  is(objectStore.name, objectStoreName, "Bad name");
    1.36 +  is(objectStore.keyPath, "foo", "Bad keyPath");
    1.37 +  if(objectStore.indexNames.length, 0, "Bad indexNames");
    1.38 +
    1.39 +  finishTest();
    1.40 +  yield undefined;
    1.41 +}
    1.42 +

mercurial