diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js')
-rw-r--r-- | testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js b/testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js new file mode 100644 index 0000000000..adf3be2f70 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js @@ -0,0 +1,96 @@ +// META: script=resources/support-promises.js +// META: title=Indexed DB transaction state during Structured Serializing +// META: timeout=long +'use strict'; + +promise_test(async testCase => { + const db = await createDatabase(testCase, database => { + database.createObjectStore('store'); + }); + + const transaction = db.transaction(['store'], 'readwrite'); + const objectStore = transaction.objectStore('store'); + + let getterCalled = false; + const activeValue = {}; + Object.defineProperty(activeValue, 'propertyName', { + enumerable: true, + get: testCase.step_func(() => { + getterCalled = true; + assert_throws_dom('TransactionInactiveError', () => { + objectStore.get('key'); + }, 'transaction should not be active during structured clone'); + return 'value that should not be used'; + }), + }); + objectStore.add(activeValue, 'key'); + await promiseForTransaction(testCase, transaction); + db.close(); + + assert_true(getterCalled, + "activeValue's getter should be called during test"); +}, 'Transaction inactive during structured clone in IDBObjectStore.add()'); + +promise_test(async testCase => { + const db = await createDatabase(testCase, database => { + database.createObjectStore('store'); + }); + + const transaction = db.transaction(['store'], 'readwrite'); + const objectStore = transaction.objectStore('store'); + + let getterCalled = false; + const activeValue = {}; + Object.defineProperty(activeValue, 'propertyName', { + enumerable: true, + get: testCase.step_func(() => { + getterCalled = true; + assert_throws_dom('TransactionInactiveError', () => { + objectStore.get('key'); + }, 'transaction should not be active during structured clone'); + return 'value that should not be used'; + }), + }); + + objectStore.put(activeValue, 'key'); + await promiseForTransaction(testCase, transaction); + db.close(); + + assert_true(getterCalled, + "activeValue's getter should be called during test"); +}, 'Transaction inactive during structured clone in IDBObjectStore.put()'); + +promise_test(async testCase => { + const db = await createDatabase(testCase, database => { + const objectStore = database.createObjectStore('store'); + objectStore.put({}, 'key'); + }); + + const transaction = db.transaction(['store'], 'readwrite'); + const objectStore = transaction.objectStore('store'); + + let getterCalled = false; + const activeValue = {}; + Object.defineProperty(activeValue, 'propertyName', { + enumerable: true, + get: testCase.step_func(() => { + getterCalled = true; + assert_throws_dom('TransactionInactiveError', () => { + objectStore.get('key'); + }, 'transaction should not be active during structured clone'); + return 'value that should not be used'; + }), + }); + + const request = objectStore.openCursor(); + request.onsuccess = testCase.step_func(() => { + const cursor = request.result; + cursor.update(activeValue); + }); + + await promiseForTransaction(testCase, transaction); + db.close(); + + assert_true(getterCalled, + "activeValue's getter should be called during test"); +}, 'Transaction inactive during structured clone in IDBCursor.update()'); |