diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/indexedDB/test/unit/test_constraint_error_messages.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/indexedDB/test/unit/test_constraint_error_messages.js')
-rw-r--r-- | dom/indexedDB/test/unit/test_constraint_error_messages.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_constraint_error_messages.js b/dom/indexedDB/test/unit/test_constraint_error_messages.js new file mode 100644 index 0000000000..b77431e71a --- /dev/null +++ b/dom/indexedDB/test/unit/test_constraint_error_messages.js @@ -0,0 +1,64 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/* exported testSteps */ +async function testSteps() { + const name = this.window ? window.location.pathname : "Splendid Test"; + const objectStoreName = "foo"; + const indexName = "bar", + keyPath = "bar"; + + info("Opening database"); + + let request = indexedDB.open(name); + let event = await expectingUpgrade(request); + + let db = event.target.result; + + info("Creating objectStore"); + + let objectStore = db.createObjectStore(objectStoreName); + + info("Creating a duplicated object store to get an error"); + + try { + db.createObjectStore(objectStoreName); + ok( + false, + "ConstraintError should be thrown if object store already exists" + ); + } catch (e) { + ok(true, "ConstraintError should be thrown if object store already exists"); + is( + e.message, + "IDBDatabase.createObjectStore: Object store named '" + + objectStoreName + + "' already exists at index '0'", + "Threw with correct error message" + ); + } + + info("Creating an index"); + + objectStore.createIndex(indexName, keyPath); + + info("Creating a duplicated indexes to verify the error message"); + + try { + objectStore.createIndex(indexName, keyPath); + + ok(false, "ConstraintError should be thrown if index already exists"); + } catch (e) { + ok(true, "ConstraintError should be thrown if index already exists"); + is( + e.message, + `IDBObjectStore.createIndex: Index named '${indexName}' already exists at index '0'`, + "Threw with correct error message" + ); + } + + await expectingSuccess(request); + db.close(); +} |