summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/unit/test_remove_index.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/indexedDB/test/unit/test_remove_index.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/indexedDB/test/unit/test_remove_index.js')
-rw-r--r--dom/indexedDB/test/unit/test_remove_index.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_remove_index.js b/dom/indexedDB/test/unit/test_remove_index.js
new file mode 100644
index 000000000..d9916b975
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_remove_index.js
@@ -0,0 +1,58 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var testGenerator = testSteps();
+
+function testSteps()
+{
+ const name = this.window ? window.location.pathname : "Splendid Test";
+ const indexName = "My Test Index";
+
+ let request = indexedDB.open(name, 1);
+ request.onerror = errorHandler;
+ request.onupgradeneeded = grabEventAndContinueHandler;
+ let event = yield undefined;
+
+ let db = event.target.result;
+ is(db.objectStoreNames.length, 0, "Correct objectStoreNames list");
+
+ let objectStore = db.createObjectStore("test store", { keyPath: "foo" });
+ is(db.objectStoreNames.length, 1, "Correct objectStoreNames list");
+ is(db.objectStoreNames.item(0), objectStore.name, "Correct name");
+
+ is(objectStore.indexNames.length, 0, "Correct indexNames list");
+
+ let index = objectStore.createIndex(indexName, "foo");
+
+ is(objectStore.indexNames.length, 1, "Correct indexNames list");
+ is(objectStore.indexNames.item(0), indexName, "Correct name");
+ is(objectStore.index(indexName), index, "Correct instance");
+
+ objectStore.deleteIndex(indexName);
+
+ is(objectStore.indexNames.length, 0, "Correct indexNames list");
+ try {
+ objectStore.index(indexName);
+ ok(false, "should have thrown");
+ }
+ catch(ex) {
+ ok(ex instanceof DOMException, "Got a DOMException");
+ is(ex.name, "NotFoundError", "expect a NotFoundError");
+ is(ex.code, DOMException.NOT_FOUND_ERR, "expect a NOT_FOUND_ERR");
+ }
+
+ let index2 = objectStore.createIndex(indexName, "foo");
+ isnot(index, index2, "New instance should be created");
+
+ is(objectStore.indexNames.length, 1, "Correct recreacted indexNames list");
+ is(objectStore.indexNames.item(0), indexName, "Correct recreacted name");
+ is(objectStore.index(indexName), index2, "Correct instance");
+
+ event.target.transaction.oncomplete = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ finishTest();
+ yield undefined;
+}