mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update web-platform-tests to revision 388ba3a049a3473b1945b9f8f81e9d6e342a249e
This commit is contained in:
parent
43e21dc845
commit
bdaf11b099
139 changed files with 3089 additions and 807 deletions
|
@ -188,20 +188,17 @@ promise_test(async testCase => {
|
|||
});
|
||||
// Txn1 should commit before txn2, even though txn2 uses commit().
|
||||
const txn1 = db.transaction(['books'], 'readwrite');
|
||||
const objectStore1 = txn1.objectStore('books');
|
||||
const putRequest1 = objectStore1.put({isbn:'one', title:'title1'});
|
||||
txn1.objectStore('books').put({isbn: 'one', title: 'title1'});
|
||||
const releaseTxnFunction = keepAlive(testCase, txn1, 'books');
|
||||
|
||||
const txn2 = db.transaction(['books'], 'readwrite');
|
||||
const objectStore2 = txn2.objectStore('books');
|
||||
const putRequest2 = objectStore2.put({isbn:'one', title:'title2'});
|
||||
txn2.objectStore('books').put({isbn:'one', title:'title2'});
|
||||
txn2.commit();
|
||||
|
||||
// Exercise the IndexedDB transaction ordering by executing one with a
|
||||
// different scope.
|
||||
const txn3 = db.transaction(['not_books'], 'readwrite');
|
||||
const objectStore3 = txn3.objectStore('not_books');
|
||||
objectStore3.put({'title': 'not_title'}, 'key');
|
||||
txn3.objectStore('not_books').put({'title': 'not_title'}, 'key');
|
||||
txn3.oncomplete = function() {
|
||||
releaseTxnFunction();
|
||||
}
|
||||
|
@ -210,8 +207,7 @@ promise_test(async testCase => {
|
|||
|
||||
// Read the data back to verify that txn2 executed last.
|
||||
const txn4 = db.transaction(['books'], 'readonly');
|
||||
const objectStore4 = txn4.objectStore('books');
|
||||
const getRequest4 = objectStore4.get('one');
|
||||
const getRequest4 = txn4.objectStore('books').get('one');
|
||||
await promiseForTransaction(testCase, txn4);
|
||||
assert_equals(getRequest4.result.title, 'title2');
|
||||
db.close();
|
||||
|
@ -225,8 +221,7 @@ promise_test(async testCase => {
|
|||
});
|
||||
// Txn1 creates the book 'one' so the 'add()' below fails.
|
||||
const txn1 = db.transaction(['books'], 'readwrite');
|
||||
const objectStore1 = txn1.objectStore('books');
|
||||
const putRequest1 = objectStore1.add({isbn:'one', title:'title1'});
|
||||
txn1.objectStore('books').add({isbn:'one', title:'title1'});
|
||||
txn1.commit();
|
||||
await promiseForTransaction(testCase, txn1);
|
||||
|
||||
|
@ -235,15 +230,17 @@ promise_test(async testCase => {
|
|||
const txn2 = db.transaction(['books'], 'readwrite');
|
||||
const objectStore2 = txn2.objectStore('books');
|
||||
objectStore2.put({isbn:'two', title:'title2'});
|
||||
const addRequest2 = objectStore2.add({isbn:'one', title:'title2'});
|
||||
const addRequest = objectStore2.add({isbn:'one', title:'title2'});
|
||||
txn2.commit();
|
||||
txn2.oncomplete = assert_unreached(
|
||||
'Transaction with invalid "add" call should not be completed.');
|
||||
txn2.oncomplete = () => { assert_unreached(
|
||||
'Transaction with invalid "add" call should not be completed.'); };
|
||||
|
||||
var addWatcher = requestWatcher(testCase, addRequest2);
|
||||
var txnWatcher = transactionWatcher(testCase, txn2);
|
||||
await Promise.all([addWatcher.wait_for('error'),
|
||||
txnWatcher.wait_for('error', 'abort')]);
|
||||
// Wait for the transaction to complete. We have to explicitly wait for the
|
||||
// error signal on the transaction because of the nature of the test tooling.
|
||||
await Promise.all([
|
||||
requestWatcher(testCase, addRequest).wait_for('error'),
|
||||
transactionWatcher(testCase, txn2).wait_for(['error', 'abort'])
|
||||
]);
|
||||
|
||||
// Read the data back to verify that txn2 was aborted.
|
||||
const txn3 = db.transaction(['books'], 'readonly');
|
||||
|
@ -255,3 +252,41 @@ promise_test(async testCase => {
|
|||
assert_equals(getRequest2.result, 0);
|
||||
db.close();
|
||||
}, 'Transactions that explicitly commit and have errors should abort.');
|
||||
|
||||
|
||||
promise_test(async testCase => {
|
||||
const db = await createDatabase(testCase, db => {
|
||||
createBooksStore(testCase, db);
|
||||
});
|
||||
const txn1 = db.transaction(['books'], 'readwrite');
|
||||
txn1.objectStore('books').add({isbn: 'one', title: 'title1'});
|
||||
txn1.commit();
|
||||
await promiseForTransaction(testCase, txn1);
|
||||
|
||||
// The second add request will throw an error, but the onerror handler will
|
||||
// appropriately catch the error allowing the valid put request on the
|
||||
// transaction to commit.
|
||||
const txn2 = db.transaction(['books'], 'readwrite');
|
||||
const objectStore2 = txn2.objectStore('books');
|
||||
objectStore2.put({isbn: 'two', title:'title2'});
|
||||
const addRequest = objectStore2.add({isbn: 'one', title:'unreached_title'});
|
||||
addRequest.onerror = (event) => {
|
||||
event.preventDefault();
|
||||
addRequest.transaction.commit();
|
||||
};
|
||||
|
||||
// Wait for the transaction to complete. We have to explicitly wait for the
|
||||
// error signal on the transaction because of the nature of the test tooling.
|
||||
await transactionWatcher(testCase,txn2).wait_for(['error', 'complete'])
|
||||
|
||||
// Read the data back to verify that txn2 was committed.
|
||||
const txn3 = db.transaction(['books'], 'readonly');
|
||||
const objectStore3 = txn3.objectStore('books');
|
||||
const getRequest1 = objectStore3.get('one');
|
||||
const getRequest2 = objectStore3.get('two');
|
||||
await promiseForTransaction(testCase, txn3);
|
||||
assert_equals(getRequest1.result.title, 'title1');
|
||||
assert_equals(getRequest2.result.title, 'title2');
|
||||
db.close();
|
||||
}, 'Transactions that handle all errors properly should be behave as ' +
|
||||
'expected when an explicit commit is called in an onerror handler.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue