Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1558)

Unified Diff: third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-settimeout.html

Issue 2592943002: DO NOT LAND: Problematic IndexedDB transaction lifecycle tests.
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-settimeout.html
diff --git a/third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-settimeout.html b/third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-settimeout.html
new file mode 100644
index 0000000000000000000000000000000000000000..2a4e85aa6548c1129d8ccb6132b7bac006bc0a0d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-settimeout.html
@@ -0,0 +1,166 @@
+<!doctype html>
+<meta charset="utf8">
+<title>IndexedDB: backend-aborted versionchange transaction lifecycle</title>
+<link rel="help"
+ href="https://w3c.github.io/IndexedDB/#upgrade-transaction-steps">
+<link rel="help"
+ href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-createobjectstore">
+<link rel="help"
+ href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-deleteobjectstore">
+<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="resources/support-promises.js"></script>
+<script>
+'use strict';
+
+promise_test(t => {
+ return createDatabase(t, database => {
+ createBooksStore(t, database);
+ }).then(database => {
+ database.close();
+ }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
+ createNotBooksStore(t, database);
+
+ // Queue I/O operations to make it very unlikely that the transaction would
+ // finish before setTimeout's callback is called.
+ const store = transaction.objectStore('books');
+ for (let i = 0; i < 1000; ++i)
+ store.put({ title: 'Bedrock Nights ' + i, author: 'Barney' });
+
+ let abortFired = false;
+ const abortPromise = new Promise((resolve, reject) => {
+ transaction.addEventListener('abort', () => {
+ abortFired = true;
+ resolve();
+ }, false);
+ transaction.objectStore('books').add(BOOKS_RECORD_DATA[0]);
+ transaction._willBeAborted();
+ });
+
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ const testStepPromise = new Promise((resolve, reject) => {
+ assert_false(
+ abortFired,
+ 'The abort event should fire after setTimeout expires');
+ assert_equals(
+ request.transaction, transaction,
+ "The open request's transaction should be reset after onabort");
+ assert_throws(
+ 'TransactionInactiveError',
+ () => { database.createObjectStore('books2'); },
+ 'createObjectStore exception should reflect that the ' +
+ 'transaction is still running');
+ assert_throws(
+ 'TransactionInactiveError',
+ () => { database.deleteObjectStore('books'); },
+ 'deleteObjectStore exception should reflect that the ' +
+ 'transaction is still running');
+ resolve();
+ });
+ resolve(testStepPromise);
+ }, 0);
+ }).then(() => abortPromise);
+ }));
+}, 'in a setTimeout(0) callback after a failing request is issued, before ' +
+ 'the transaction abort event is fired');
+
+promise_test(t => {
+ return createDatabase(t, database => {
+ createBooksStore(t, database);
+ }).then(database => {
+ database.close();
+ }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
+ // Queue I/O operations to make it very unlikely that the transaction would
+ // finish before setTimeout's callback is called.
+ createNotBooksStore(t, database);
+ const store = transaction.objectStore('books');
+ for (let i = 0; i < 1000; ++i)
+ store.put({ title: 'Bedrock Nights ' + i, author: 'Barney' });
+
+ let abortFired = false;
+ const abortPromise = new Promise((resolve, reject) => {
+ transaction.addEventListener('abort', () => {
+ abortFired = true;
+ resolve();
+ }, false);
+ transaction.abort();
+ });
+
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ resolve(new Promise((resolve, reject) => {
+ assert_false(
+ abortFired,
+ 'The abort event should fire after setTimeout expires');
+ assert_equals(
+ request.transaction, transaction,
+ "The open request's transaction should be reset after onabort");
+ assert_throws(
+ 'TransactionInactiveError',
+ () => { database.createObjectStore('books2'); },
+ 'createObjectStore exception should reflect that the ' +
+ 'transaction is still running');
+ assert_throws(
+ 'TransactionInactiveError',
+ () => { database.deleteObjectStore('books'); },
+ 'deleteObjectStore exception should reflect that the ' +
+ 'transaction is still running');
+ resolve();
+ }));
+ }, 0);
+ }).then(() => abortPromise);
+ }));
+}, 'in a setTimeout(0) callback after abort() is called, before the ' +
+ 'transaction abort event is fired');
+
+promise_test(t => {
+ return createDatabase(t, database => {
+ createBooksStore(t, database);
+ }).then(database => {
+ database.close();
+ }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
+ // Queue I/O operations to make it very unlikely that the transaction would
+ // finish before setTimeout's callback is called.
+ createNotBooksStore(t, database);
+ const store = transaction.objectStore('books');
+ for (let i = 0; i < 1000; ++i)
+ store.put({ title: 'Bedrock Nights ' + i, author: 'Barney' });
+
+ let completeFired = false;
+ const completePromise = new Promise((resolve, reject) => {
+ transaction.addEventListener('complete', () => {
+ completeFired = true;
+ resolve();
+ }, false);
+ });
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ resolve(new Promise((resolve, reject) => {
+ assert_false(
+ completeFired,
+ 'The complete event should fire after setTimeout expires');
+ assert_equals(
+ request.transaction, transaction,
+ "The open request's transaction should be reset after " +
+ 'oncomplete');
+ assert_throws(
+ 'TransactionInactiveError',
+ () => { database.createObjectStore('books2'); },
+ 'createObjectStore exception should reflect that the ' +
+ 'transaction is still running');
+ assert_throws(
+ 'TransactionInactiveError',
+ () => { database.deleteObjectStore('books'); },
+ 'deleteObjectStore exception should reflect that the ' +
+ 'transaction is still running');
+ resolve();
+ }));
+ }, 0);
+ }).then(() => completePromise);
+ })).then(database => { database.close(); });
+}, 'in a setTimeout(0) callback after the transaction requests are performed,' +
+ 'before the transaction complete event is fired');
+
+</script>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698