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

Side by Side 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 3 years, 12 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 | « no previous file | 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: 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 createNotBooksStore(t, database);
24
25 // Queue I/O operations to make it very unlikely that the transaction would
26 // finish before setTimeout's callback is called.
27 const store = transaction.objectStore('books');
28 for (let i = 0; i < 1000; ++i)
29 store.put({ title: 'Bedrock Nights ' + i, author: 'Barney' });
30
31 let abortFired = false;
32 const abortPromise = new Promise((resolve, reject) => {
33 transaction.addEventListener('abort', () => {
34 abortFired = true;
35 resolve();
36 }, false);
37 transaction.objectStore('books').add(BOOKS_RECORD_DATA[0]);
38 transaction._willBeAborted();
39 });
40
41 return new Promise((resolve, reject) => {
42 setTimeout(() => {
43 const testStepPromise = new Promise((resolve, reject) => {
44 assert_false(
45 abortFired,
46 'The abort event should fire after setTimeout expires');
47 assert_equals(
48 request.transaction, transaction,
49 "The open request's transaction should be reset after onabort");
50 assert_throws(
51 'TransactionInactiveError',
52 () => { database.createObjectStore('books2'); },
53 'createObjectStore exception should reflect that the ' +
54 'transaction is still running');
55 assert_throws(
56 'TransactionInactiveError',
57 () => { database.deleteObjectStore('books'); },
58 'deleteObjectStore exception should reflect that the ' +
59 'transaction is still running');
60 resolve();
61 });
62 resolve(testStepPromise);
63 }, 0);
64 }).then(() => abortPromise);
65 }));
66 }, 'in a setTimeout(0) callback after a failing request is issued, before ' +
67 'the transaction abort event is fired');
68
69 promise_test(t => {
70 return createDatabase(t, database => {
71 createBooksStore(t, database);
72 }).then(database => {
73 database.close();
74 }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
75 // Queue I/O operations to make it very unlikely that the transaction would
76 // finish before setTimeout's callback is called.
77 createNotBooksStore(t, database);
78 const store = transaction.objectStore('books');
79 for (let i = 0; i < 1000; ++i)
80 store.put({ title: 'Bedrock Nights ' + i, author: 'Barney' });
81
82 let abortFired = false;
83 const abortPromise = new Promise((resolve, reject) => {
84 transaction.addEventListener('abort', () => {
85 abortFired = true;
86 resolve();
87 }, false);
88 transaction.abort();
89 });
90
91 return new Promise((resolve, reject) => {
92 setTimeout(() => {
93 resolve(new Promise((resolve, reject) => {
94 assert_false(
95 abortFired,
96 'The abort event should fire after setTimeout expires');
97 assert_equals(
98 request.transaction, transaction,
99 "The open request's transaction should be reset after onabort");
100 assert_throws(
101 'TransactionInactiveError',
102 () => { database.createObjectStore('books2'); },
103 'createObjectStore exception should reflect that the ' +
104 'transaction is still running');
105 assert_throws(
106 'TransactionInactiveError',
107 () => { database.deleteObjectStore('books'); },
108 'deleteObjectStore exception should reflect that the ' +
109 'transaction is still running');
110 resolve();
111 }));
112 }, 0);
113 }).then(() => abortPromise);
114 }));
115 }, 'in a setTimeout(0) callback after abort() is called, before the ' +
116 'transaction abort event is fired');
117
118 promise_test(t => {
119 return createDatabase(t, database => {
120 createBooksStore(t, database);
121 }).then(database => {
122 database.close();
123 }).then(() => migrateDatabase(t, 2, (database, transaction, request) => {
124 // Queue I/O operations to make it very unlikely that the transaction would
125 // finish before setTimeout's callback is called.
126 createNotBooksStore(t, database);
127 const store = transaction.objectStore('books');
128 for (let i = 0; i < 1000; ++i)
129 store.put({ title: 'Bedrock Nights ' + i, author: 'Barney' });
130
131 let completeFired = false;
132 const completePromise = new Promise((resolve, reject) => {
133 transaction.addEventListener('complete', () => {
134 completeFired = true;
135 resolve();
136 }, false);
137 });
138 return new Promise((resolve, reject) => {
139 setTimeout(() => {
140 resolve(new Promise((resolve, reject) => {
141 assert_false(
142 completeFired,
143 'The complete event should fire after setTimeout expires');
144 assert_equals(
145 request.transaction, transaction,
146 "The open request's transaction should be reset after " +
147 'oncomplete');
148 assert_throws(
149 'TransactionInactiveError',
150 () => { database.createObjectStore('books2'); },
151 'createObjectStore exception should reflect that the ' +
152 'transaction is still running');
153 assert_throws(
154 'TransactionInactiveError',
155 () => { database.deleteObjectStore('books'); },
156 'deleteObjectStore exception should reflect that the ' +
157 'transaction is still running');
158 resolve();
159 }));
160 }, 0);
161 }).then(() => completePromise);
162 })).then(database => { database.close(); });
163 }, 'in a setTimeout(0) callback after the transaction requests are performed,' +
164 'before the transaction complete event is fired');
165
166 </script>
OLDNEW
« 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