Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
19 changed files
with
322 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Index cursor - indexed values updated during iteration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Index cursor - indexed values updated during iteration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Cross-Origin-Embedder-Policy: require-corp | ||
Cross-Origin-Opener-Policy: same-origin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.