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

Side by Side Diff: third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-user-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
« no previous file with comments | « third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-microtasks.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset="utf8">
3 <title>IndexedDB: user-abort()ed 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 transaction.abort();
24 assert_equals(
25 request.transaction, transaction,
26 "The open request's transaction should be reset after onabort");
27
28 assert_throws(
29 'TransactionInactiveError',
30 () => { database.createObjectStore('books2'); },
31 'createObjectStore exception should reflect that the transaction is ' +
32 'still running');
33 assert_throws(
34 'TransactionInactiveError',
35 () => { database.deleteObjectStore('books'); },
36 'deleteObjectStore exception should reflect that the transaction is' +
37 'still running');
38 }));
39 }, 'synchronously after abort() is called');
40
41 promise_test(t => {
42 return createDatabase(t, database => {
43 createBooksStore(t, database);
44 }).then(database => {
45 database.close();
46 }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
47 let abortFired = false;
48 const abortPromise = new Promise((resolve, reject) => {
49 transaction.addEventListener('abort', () => {
50 abortFired = true;
51 resolve();
52 }, false);
53 transaction.abort();
54 });
55
56 return Promise.resolve().then(() => {
57 assert_false(
58 abortFired,
59 'The abort event should fire after promises are resolved');
60 assert_equals(
61 request.transaction, transaction,
62 "The open request's transaction should be reset after onabort");
63 assert_throws(
64 'TransactionInactiveError',
65 () => { database.createObjectStore('books2'); },
66 'createObjectStore exception should reflect that the transaction ' +
67 'is still running');
68 assert_throws(
69 'TransactionInactiveError',
70 () => { database.deleteObjectStore('books'); },
71 'deleteObjectStore exception should reflect that the transaction ' +
72 'is still running');
73 }).then(() => abortPromise);
74 }));
75 }, 'in a promise microtask after abort() is called, before the transaction ' +
76 'abort event is fired');
77
78 promise_test(t => {
79 return createDatabase(t, database => {
80 createBooksStore(t, database);
81 }).then(database => {
82 database.close();
83 }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
84 return new Promise((resolve, reject) => {
85 transaction.addEventListener('abort', () => {
86 resolve(new Promise((resolve, reject) => {
87 assert_equals(
88 request.transaction, transaction,
89 "The open request's transaction should be reset after onabort");
90 assert_throws(
91 'InvalidStateError',
92 () => { database.createObjectStore('books2'); },
93 'createObjectStore exception should reflect that the ' +
94 'transaction is no longer running');
95 assert_throws(
96 'InvalidStateError',
97 () => { database.deleteObjectStore('books'); },
98 'deleteObjectStore exception should reflect that the ' +
99 'transaction is no longer running');
100 resolve();
101 }));
102 }, false);
103 transaction.abort();
104 });
105 }));
106 }, 'in the abort event handler for a transaction aborted due to an abort() ' +
107 'call');
108
109 promise_test(t => {
110 return createDatabase(t, database => {
111 createBooksStore(t, database);
112 }).then(database => {
113 database.close();
114 }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
115 return new Promise((resolve, reject) => {
116 transaction.addEventListener('abort', () => {
117 setTimeout(() => {
118 resolve(new Promise((resolve, reject) => {
119 assert_equals(
120 request.transaction, null,
121 "The open request's transaction should be reset after " +
122 'onabort microtasks');
123 assert_throws(
124 'InvalidStateError',
125 () => { database.createObjectStore('books2'); },
126 'createObjectStore exception should reflect that the ' +
127 'transaction is no longer running');
128 assert_throws(
129 'InvalidStateError',
130 () => { database.deleteObjectStore('books'); },
131 'deleteObjectStore exception should reflect that the ' +
132 'transaction is no longer running');
133 resolve();
134 }));
135 }, 0);
136 }, false);
137 transaction.abort();
138 });
139 }));
140 }, 'in a setTimeout(0) callback after the abort event is fired for a ' +
141 'transaction aborted due to an abort() call');
142
143 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/storage/indexeddb/upgrade-transaction-lifecycle-microtasks.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698