summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js
parentInitial commit. (diff)
downloadfirefox-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 'testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js')
-rw-r--r--testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js96
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()');