diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/indexedDB/test/unit/test_cursor_cycle.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/indexedDB/test/unit/test_cursor_cycle.js')
-rw-r--r-- | dom/indexedDB/test/unit/test_cursor_cycle.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_cursor_cycle.js b/dom/indexedDB/test/unit/test_cursor_cycle.js new file mode 100644 index 0000000000..e7a93a2d93 --- /dev/null +++ b/dom/indexedDB/test/unit/test_cursor_cycle.js @@ -0,0 +1,48 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/* exported testGenerator */ +var testGenerator = testSteps(); + +function* testSteps() { + const Bob = { ss: "237-23-7732", name: "Bob" }; + + let request = indexedDB.open( + this.window ? window.location.pathname : "Splendid Test", + 1 + ); + request.onerror = errorHandler; + request.onupgradeneeded = grabEventAndContinueHandler; + let event = yield undefined; + + let db = event.target.result; + event.target.onsuccess = continueToNextStep; + + let objectStore = db.createObjectStore("foo", { keyPath: "ss" }); + objectStore.createIndex("name", "name", { unique: true }); + objectStore.add(Bob); + yield undefined; + + db + .transaction("foo", "readwrite") + .objectStore("foo") + .index("name") + .openCursor().onsuccess = function(event) { + event.target.transaction.oncomplete = continueToNextStep; + let cursor = event.target.result; + if (cursor) { + let objectStore = event.target.transaction.objectStore("foo"); + objectStore.delete(Bob.ss).onsuccess = function(event) { + cursor.continue(); + }; + } + }; + yield undefined; + finishTest(); + + objectStore = null; // Bug 943409 workaround. + + yield undefined; +} |