summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js
diff options
context:
space:
mode:
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()');