fune/testing/web-platform/tests/IndexedDB/structured-clone-transaction-state.any.js
Ari Chivukula 8dd06510b1 Bug 1770831 [wpt PR 34171] - [IndexedDB] Cleanup WPT directory, a=testonly
Automatic update from web-platform-tests
[IndexedDB] Cleanup WPT directory

Some common/resource files were in the root directory. This moves them
to the /resources/ directory and fixes up include paths.

Bug: 1218100
Change-Id: If84f7d1670e9416c95eb0fd96de63add4dcacedf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3661378
Auto-Submit: Ari Chivukula <arichiv@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1006619}

--

wpt-commits: 96ea2c2b7bf09644db195f0d878074615faef9e4
wpt-pr: 34171
2022-05-25 08:46:09 +00:00

96 lines
3.1 KiB
JavaScript

// 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()');