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

Side by Side Diff: third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-backend-aborted.html

Issue 2556373003: Tests for exceptions related to IndexedDB upgrade transaction lifecycle. (Closed)
Patch Set: Addressed feedback. Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset="utf8">
3 <title>IndexedDB: backend-aborted versionchange transaction lifecycle</title>
4 <link rel="help"
5 href="https://w3c.github.io/IndexedDB/#upgrade-transaction-steps">
6 <link rel="help"
7 href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-createobjectstore">
8 <link rel="help"
9 href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-deleteobjectstore">
10 <link rel="author" href="pwnall@chromium.org" title="Victor Costan">
11 <script src="../../resources/testharness.js"></script>
12 <script src="../../resources/testharnessreport.js"></script>
13 <script src="resources/support-promises.js"></script>
14 <script>
15 'use strict';
16
17 promise_test(t => {
18 return createDatabase(t, database => {
19 createBooksStore(t, database);
20 }).then(database => {
21 database.close();
22 }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
23 return new Promise((resolve, reject) => {
24 transaction.addEventListener('abort', () => {
25 resolve(new Promise((resolve, reject) => {
26 assert_equals(
27 request.transaction, transaction,
28 "The open request's transaction should be reset after onabort");
29 assert_throws(
30 'InvalidStateError',
31 () => { database.createObjectStore('books2'); },
32 'createObjectStore exception should reflect that the ' +
33 'transaction is no longer running');
34 assert_throws(
35 'InvalidStateError',
36 () => { database.deleteObjectStore('books'); },
37 'deleteObjectStore exception should reflect that the ' +
38 'transaction is no longer running');
39 resolve();
40 }));
41 }, false);
42 transaction.objectStore('books').add(BOOKS_RECORD_DATA[0]);
43 transaction._willBeAborted();
44 });
45 }));
46 }, 'in the abort event handler for a transaction aborted due to an unhandled ' +
47 'request error');
48
49 promise_test(t => {
50 return createDatabase(t, database => {
51 createBooksStore(t, database);
52 }).then(database => {
53 database.close();
54 }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
55 return new Promise((resolve, reject) => {
56 transaction.addEventListener('abort', () => {
57 setTimeout(() => {
58 resolve(new Promise((resolve, reject) => {
59 assert_equals(
60 request.transaction, null,
61 "The open request's transaction should be reset after " +
62 'onabort microtasks');
63 assert_throws(
64 'InvalidStateError',
65 () => { database.createObjectStore('books2'); },
66 'createObjectStore exception should reflect that the ' +
67 'transaction is no longer running');
68 assert_throws(
69 'InvalidStateError',
70 () => { database.deleteObjectStore('books'); },
71 'deleteObjectStore exception should reflect that the ' +
72 'transaction is no longer running');
73 resolve();
74 }));
75 }, 0);
76 }, false);
77 transaction.objectStore('books').add(BOOKS_RECORD_DATA[0]);
78 transaction._willBeAborted();
79 });
80 }));
81 }, 'in a setTimeout(0) callback after the abort event is fired for a ' +
82 'transaction aborted due to an unhandled request failure');
83
84 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698