diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/indexedDB/test/unit/test_unique_index_update.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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_unique_index_update.js')
-rw-r--r-- | dom/indexedDB/test/unit/test_unique_index_update.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_unique_index_update.js b/dom/indexedDB/test/unit/test_unique_index_update.js new file mode 100644 index 000000000..97caef324 --- /dev/null +++ b/dom/indexedDB/test/unit/test_unique_index_update.js @@ -0,0 +1,64 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +var testGenerator = testSteps(); + +function testSteps() +{ + let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1); + request.onerror = errorHandler; + request.onupgradeneeded = grabEventAndContinueHandler; + request.onsuccess = grabEventAndContinueHandler; + + let event = yield undefined; + + let db = event.target.result; + + for (let autoIncrement of [false, true]) { + let objectStore = + db.createObjectStore(autoIncrement, { keyPath: "id", + autoIncrement: autoIncrement }); + objectStore.createIndex("", "index", { unique: true }); + + for (let i = 0; i < 10; i++) { + objectStore.add({ id: i, index: i }); + } + } + + event = yield undefined; + is(event.type, "success", "expect a success event"); + + for (let autoIncrement of [false, true]) { + objectStore = db.transaction(autoIncrement, "readwrite") + .objectStore(autoIncrement); + + request = objectStore.put({ id: 5, index: 6 }); + request.onsuccess = unexpectedSuccessHandler; + request.addEventListener("error", new ExpectError("ConstraintError", true)); + event = yield undefined; + + event.preventDefault(); + + let keyRange = IDBKeyRange.only(5); + + objectStore.index("").openCursor(keyRange).onsuccess = function(event) { + let cursor = event.target.result; + ok(cursor, "Must have a cursor here"); + + is(cursor.value.index, 5, "Still have the right index value"); + + cursor.value.index = 6; + + request = cursor.update(cursor.value); + request.onsuccess = unexpectedSuccessHandler; + request.addEventListener("error", new ExpectError("ConstraintError", true)); + }; + + yield undefined; + } + + finishTest(); + yield undefined; +} |