Skip to content
Permalink
Browse files
Resync IndexedDB WPT tests from upstream
https://bugs.webkit.org/show_bug.cgi?id=227315

Reviewed by Darin Adler.

Resync IndexedDB WPT tests from upstream a38612f39e7752c3532080c.

* web-platform-tests/IndexedDB/*: Updated.


Canonical link: https://commits.webkit.org/239083@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Jun 23, 2021
1 parent 1708556 commit 49912a15a7d8ed5321601eeb03b9187c89b3c475
Show file tree
Hide file tree
Showing 19 changed files with 322 additions and 20 deletions.
@@ -1,3 +1,14 @@
2021-06-23 Chris Dumez <cdumez@apple.com>

Resync IndexedDB WPT tests from upstream
https://bugs.webkit.org/show_bug.cgi?id=227315

Reviewed by Darin Adler.

Resync IndexedDB WPT tests from upstream a38612f39e7752c3532080c.

* web-platform-tests/IndexedDB/*: Updated.

2021-06-23 Chris Dumez <cdumez@apple.com>

REGRESSION (r279169?): [MacOS] imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video_timeupdate_on_seek.html is consistently failing.
@@ -1,13 +1,5 @@
// META: script=support-promises.js

/**
* This file contains a test that was separated out from the rest of the idb
* explict commit tests because it requires the flag 'allow_uncaught_exception',
* which prevents unintentionally thrown errors from failing tests.
*
* @author andreasbutler@google.com
*/

setup({allow_uncaught_exception:true});

promise_test(async testCase => {
@@ -1,12 +1,5 @@
// META: script=support-promises.js

/**
* This file contains the webplatform tests for the explicit commit() method
* of the IndexedDB transaction API.
*
* @author andreasbutler@google.com
*/

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
createBooksStore(testCase, db);
@@ -0,0 +1,3 @@

PASS Index cursor - indexed values updated during iteration

@@ -0,0 +1 @@
<!-- This file is required for WebKit test infrastructure to run the templated test -->
@@ -0,0 +1,43 @@
// META: script=support-promises.js

promise_test(async t => {
const db = await createDatabase(t, db => {
const store = db.createObjectStore('store');
store.createIndex('index', 'value');
store.put({value: 1}, 1);
store.put({value: 2}, 2);
store.put({value: 3}, 3);
});

{
// Iterate over all index entries until an upper bound is reached.
// On each record found, increment the value used as the index
// key, which will make it show again up later in the iteration.
const tx = db.transaction('store', 'readwrite');
const range = IDBKeyRange.upperBound(9);
const index = tx.objectStore('store').index('index');
const request = index.openCursor(range);
request.onsuccess = t.step_func(e => {
const cursor = e.target.result;
if (!cursor)
return;

const record = cursor.value;
record.value += 1;
cursor.update(record);

cursor.continue();
});

await promiseForTransaction(t, tx);
}

{
const tx = db.transaction('store', 'readonly');
const results = await promiseForRequest(t, tx.objectStore('store').getAll());
assert_array_equals(
results.map(record => record.value),
[10, 10, 10],
'Values should all be incremented until bound reached');
}
}, 'Index cursor - indexed values updated during iteration');
@@ -0,0 +1,3 @@

PASS Index cursor - indexed values updated during iteration

@@ -0,0 +1 @@
<!-- This file is required for WebKit test infrastructure to run the templated test -->
@@ -0,0 +1,12 @@

FAIL Data can be successfully inserted into an object store using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues(values)', 'objectStore.putAllValues' is undefined)"
FAIL Values with array keys can be successfully inserted into an object store using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues(values)', 'objectStore.putAllValues' is undefined)"
FAIL Inserting an empty list using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([])', 'objectStore.putAllValues' is undefined)"
FAIL Empty values can be inserted into an objectstore with a key generator using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([{}, {}, {}])', 'objectStore.putAllValues' is undefined)"
FAIL Attempting to insert with a read only transaction using putAll throws a ReadOnlyError. assert_throws_dom: The transaction is readonly function "() => { objectStore.putAllValues([{}]); }" threw object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([{}])', 'objectStore.putAllValues' is undefined)" that is not a DOMException ReadOnlyError: property "code" is equal to undefined, expected 0
FAIL Inserting duplicate unique keys into a store that already has the keyusing putAll throws a ConstraintError. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([
{isbn: 2, title: "duplicate"},
{isbn: 3, title: "duplicate"}
])', 'objectStore.putAllValues' is undefined)"
FAIL Inserting values without the key into an object store that does not have generated keys throws an exception. assert_throws_dom: Evaluating the object store's key path did not yield a value function "() => { const putAllRequest = objectStore.putAllValues(values); }" threw object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues(values)', 'objectStore.putAllValues' is undefined)" that is not a DOMException DataError: property "code" is equal to undefined, expected 0

@@ -0,0 +1 @@
<!-- This file is required for WebKit test infrastructure to run the templated test -->
@@ -0,0 +1,180 @@
// META: script=support-promises.js

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db);
});
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
const values = [
{isbn: 'one', title: 'title1'},
{isbn: 'two', title: 'title2'},
{isbn: 'three', title: 'title3'}
];
const putAllRequest = objectStore.putAllValues(values);
// TODO(nums): Check that correct keys are returned.
await promiseForRequest(testCase, putAllRequest);
await promiseForTransaction(testCase, txn);

const txn2 = db.transaction(['books'], 'readonly');
const objectStore2 = txn2.objectStore('books');
const getRequest1 = objectStore2.get('one');
const getRequest2 = objectStore2.get('two');
const getRequest3 = objectStore2.get('three');
await promiseForTransaction(testCase, txn2);
assert_array_equals(
[getRequest1.result.title,
getRequest2.result.title,
getRequest3.result.title],
['title1', 'title2', 'title3'],
'All three retrieved titles should match those that were put.');
db.close();
}, 'Data can be successfully inserted into an object store using putAll.');

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db);
});
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
const values = [
{isbn: ['one', 'two', 'three'], title: 'title1'},
{isbn: ['four', 'five', 'six'], title: 'title2'},
{isbn: ['seven', 'eight', 'nine'], title: 'title3'}
];
const putAllRequest = objectStore.putAllValues(values);
// TODO(nums): Check that correct keys are returned.
await promiseForRequest(testCase, putAllRequest);
await promiseForTransaction(testCase, txn);

const txn2 = db.transaction(['books'], 'readonly');
const objectStore2 = txn2.objectStore('books');
const getRequest1 = objectStore2.get(['one', 'two', 'three']);
const getRequest2 = objectStore2.get(['four', 'five', 'six']);
const getRequest3 = objectStore2.get(['seven', 'eight', 'nine']);
await promiseForTransaction(testCase, txn2);
assert_array_equals(
[getRequest1.result.title,
getRequest2.result.title,
getRequest3.result.title],
['title1', 'title2', 'title3'],
'All three retrieved titles should match those that were put.');
db.close();
}, 'Values with array keys can be successfully inserted into an object'
+ ' store using putAll.');

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db);
});
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
const putAllRequest = objectStore.putAllValues([]);
await promiseForRequest(testCase, putAllRequest);
await promiseForTransaction(testCase, txn);
// TODO(nums): Check that an empty key array is returned.
db.close();
}, 'Inserting an empty list using putAll.');

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db);
});
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
const putAllRequest = objectStore.putAllValues([{}, {}, {}]);
// TODO(nums): Check that correct keys are returned.
await promiseForRequest(testCase, putAllRequest);
await promiseForTransaction(testCase, txn);

const txn2 = db.transaction(['books'], 'readonly');
const objectStore2 = txn2.objectStore('books');
const getRequest1 = objectStore2.get(1);
const getRequest2 = objectStore2.get(2);
const getRequest3 = objectStore2.get(3);
await Promise.all([
promiseForRequest(testCase, getRequest1),
promiseForRequest(testCase, getRequest2),
promiseForRequest(testCase, getRequest3),
]);
db.close();
}, 'Empty values can be inserted into an objectstore'
+ ' with a key generator using putAll.');

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db);
});
const txn = db.transaction(['books'], 'readonly');
const objectStore = txn.objectStore('books');
assert_throws_dom('ReadOnlyError',
() => { objectStore.putAllValues([{}]); },
'The transaction is readonly');
db.close();
}, 'Attempting to insert with a read only transaction using putAll throws a '
+ 'ReadOnlyError.');

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db);
});
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
const putRequest = await objectStore.put({isbn: 1, title: "duplicate"});
await promiseForRequest(testCase, putRequest);
const putAllRequest = objectStore.putAllValues([
{isbn: 2, title: "duplicate"},
{isbn: 3, title: "duplicate"}
]);
const errorEvent = await requestWatcher(testCase,
putAllRequest).wait_for('error');
assert_equals(errorEvent.target.error.name, "ConstraintError");
errorEvent.preventDefault();
// The transaction still receives the error event even though it
// isn't aborted.
await transactionWatcher(testCase, txn).wait_for(['error', 'complete']);

const txn2 = db.transaction(['books'], 'readonly');
const objectStore2 = txn2.objectStore('books');
const getRequest1 = objectStore2.get(1);
const getRequest2 = objectStore2.get(2);
const getRequest3 = objectStore2.get(3);
await promiseForTransaction(testCase, txn2);
assert_array_equals(
[getRequest1.result.title, getRequest2.result, getRequest3.result],
["duplicate", undefined, undefined],
'None of the values should have been inserted.');
db.close();
}, 'Inserting duplicate unique keys into a store that already has the key'
+ 'using putAll throws a ConstraintError.');

promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStoreWithoutAutoIncrement(testCase, db);
});
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
const values = [
{title: "title1", isbn: 1},
{title: "title2"}
];
assert_throws_dom('DataError',
() => { const putAllRequest = objectStore.putAllValues(values); },
"Evaluating the object store's key path did not yield a value");

const txn2 = db.transaction(['books'], 'readonly');
const objectStore2 = txn2.objectStore('books');
const getRequest1 = objectStore2.get(1);
const getRequest2 = objectStore2.get(2);
await promiseForTransaction(testCase, txn2);
assert_array_equals(
[getRequest1.result, getRequest2.result],
[undefined, undefined],
'No data should have been inserted');
db.close();
}, 'Inserting values without the key into an object store that'
+ ' does not have generated keys throws an exception.');

// TODO(nums): Add test for insertion into multi entry indexes
// TODO(nums): Add test for inserting unique keys into a store
// that doesn't already have the key https://crbug.com/1115649
@@ -0,0 +1,12 @@

FAIL Data can be successfully inserted into an object store using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues(values)', 'objectStore.putAllValues' is undefined)"
FAIL Values with array keys can be successfully inserted into an object store using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues(values)', 'objectStore.putAllValues' is undefined)"
FAIL Inserting an empty list using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([])', 'objectStore.putAllValues' is undefined)"
FAIL Empty values can be inserted into an objectstore with a key generator using putAll. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([{}, {}, {}])', 'objectStore.putAllValues' is undefined)"
FAIL Attempting to insert with a read only transaction using putAll throws a ReadOnlyError. assert_throws_dom: The transaction is readonly function "() => { objectStore.putAllValues([{}]); }" threw object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([{}])', 'objectStore.putAllValues' is undefined)" that is not a DOMException ReadOnlyError: property "code" is equal to undefined, expected 0
FAIL Inserting duplicate unique keys into a store that already has the keyusing putAll throws a ConstraintError. promise_test: Unhandled rejection with value: object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues([
{isbn: 2, title: "duplicate"},
{isbn: 3, title: "duplicate"}
])', 'objectStore.putAllValues' is undefined)"
FAIL Inserting values without the key into an object store that does not have generated keys throws an exception. assert_throws_dom: Evaluating the object store's key path did not yield a value function "() => { const putAllRequest = objectStore.putAllValues(values); }" threw object "TypeError: objectStore.putAllValues is not a function. (In 'objectStore.putAllValues(values)', 'objectStore.putAllValues' is undefined)" that is not a DOMException DataError: property "code" is equal to undefined, expected 0

@@ -0,0 +1 @@
<!-- This file is required for WebKit test infrastructure to run the templated test -->
@@ -0,0 +1,3 @@

FAIL IndexedDB: Attempting to serialize a SharedArrayBuffer should throw assert_true: The page is served with COOP and COEP, it should be cross-origin-isolated. expected true got undefined

@@ -0,0 +1,28 @@
<!DOCTYPE html>
<title>IndexedDB: Attempting to serialize a SharedArrayBuffer should throw</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
async_test(function(t) {

// The SAB constructor throws if the page is not cross-origin-isolated.
assert_true(self.crossOriginIsolated,
"The page is served with COOP and COEP, it should be cross-origin-isolated.");

let open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) {
let db = e.target.result;
let objStore = db.createObjectStore("test", { keyPath:"pKey" });

let sab = new SharedArrayBuffer(256);

let rq;
assert_throws_dom("DataCloneError", () => {
rq = objStore.put({sab: sab}, 'key');
});
assert_equals(rq, undefined);
t.done();
};
});
</script>
@@ -0,0 +1,2 @@
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
@@ -15,7 +15,7 @@
function describe(value) {
let type, str;
if (typeof value === 'object' && value) {
type = value.__proto__.constructor.name;
type = Object.getPrototypeOf(value).constructor.name;
// Handle Number(-0), etc.
str = Object.is(value.valueOf(), -0) ? '-0' : String(value);
} else {
@@ -54,7 +54,7 @@ function cloneObjectTest(value, verifyFunc) {
cloneTest(value, async (orig, clone) => {
assert_not_equals(orig, clone);
assert_equals(typeof clone, 'object');
assert_equals(orig.__proto__, clone.__proto__);
assert_equals(Object.getPrototypeOf(orig), Object.getPrototypeOf(clone));
await verifyFunc(orig, clone);
});
}
@@ -141,7 +141,7 @@ const strings = [
].forEach(value => cloneTest(value, (orig, clone) => {
assert_not_equals(orig, clone);
assert_equals(typeof clone, 'object');
assert_equals(orig.__proto__, clone.__proto__);
assert_equals(Object.getPrototypeOf(orig), Object.getPrototypeOf(clone));
assert_equals(orig.valueOf(), clone.valueOf());
}));

@@ -261,7 +261,7 @@ cloneObjectTest({foo: true, bar: false}, (orig, clone) => {
new DOMRect,
new DOMRectReadOnly(),
].forEach(value => cloneObjectTest(value, (orig, clone) => {
Object.keys(orig.__proto__).forEach(key => {
Object.keys(Object.getPrototypeOf(orig)).forEach(key => {
assert_equals(orig[key], clone[key], `Property ${key}`);
});
}));

0 comments on commit 49912a1

Please sign in to comment.