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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/IndexedDB/idbtransaction_objectStoreNames.html

Issue 1419013007: update-w3c-deps import using blink 83a52878976eaffc8753993a7689c9c178664fba: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 <title>IndexedDB: IDBTransaction.objectStoreNames attribute</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script>
6
7 function indexeddb_test(upgrade_func, open_func, description) {
8 async_test(function(t) {
9 var dbname = document.location + '-' + t.name;
10 var del = indexedDB.deleteDatabase(dbname);
11 del.onerror = t.unreached_func('deleteDatabase should succeed');
12 var open = indexedDB.open(dbname, 1);
13 open.onerror = t.unreached_func('open should succeed');
14 open.onupgradeneeded = t.step_func(function() {
15 var db = open.result;
16 var tx = open.transaction;
17 upgrade_func(t, db, tx);
18 });
19 open.onsuccess = t.step_func(function() {
20 var db = open.result;
21 open_func(t, db);
22 });
23 }, description);
24 }
25
26 function with_stores_test(store_names, open_func, description) {
27 indexeddb_test(function(t, db, tx) {
28 store_names.forEach(function(name) {
29 db.createObjectStore(name);
30 });
31 }, open_func, description);
32 }
33
34 indexeddb_test(function(t, db, tx) {
35 assert_array_equals(tx.objectStoreNames, [],
36 'transaction objectStoreNames should be empty');
37 assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
38 'connection and transacton objectStoreNames should match');
39
40 db.createObjectStore('s1');
41 assert_array_equals(tx.objectStoreNames, ['s1'],
42 'transaction objectStoreNames should have new store');
43 assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
44 'connection and transacton objectStoreNames should match');
45
46 db.createObjectStore('s3');
47 assert_array_equals(tx.objectStoreNames, ['s1', 's3'],
48 'transaction objectStoreNames should have new store');
49 assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
50 'connection and transacton objectStoreNames should match');
51
52 db.createObjectStore('s2');
53 assert_array_equals(tx.objectStoreNames, ['s1', 's2', 's3'],
54 'transaction objectStoreNames should be sorted');
55 assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
56 'connection and transacton objectStoreNames should match');
57
58 db.deleteObjectStore('s1');
59 assert_array_equals(tx.objectStoreNames, ['s2', 's3'],
60 'transaction objectStoreNames should be updated after delete');
61 assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
62 'connection and transacton objectStoreNames should match');
63 }, function(t, db) {
64 t.done();
65 }, 'IDBTransaction.objectStoreNames - during upgrade transaction');
66
67 (function() {
68 var saved_tx;
69 indexeddb_test(function(t, db, tx) {
70 saved_tx = tx;
71 db.createObjectStore('s2');
72 db.createObjectStore('s3');
73 }, function(t, db) {
74 db.close();
75 var open2 = indexedDB.open(db.name, db.version + 1);
76 open2.onerror = t.unreached_func('open should succeed');
77 open2.onupgradeneeded = t.step_func(function() {
78 var db2 = open2.result;
79 var tx2 = open2.transaction;
80 assert_array_equals(tx2.objectStoreNames, ['s2', 's3'],
81 'transaction should have previous stores in scope');
82 assert_array_equals(db2.objectStoreNames, tx2.objectStoreNames,
83 'connection and transacton objectStoreNames should match');
84
85 db2.createObjectStore('s4');
86 assert_array_equals(tx2.objectStoreNames, ['s2', 's3', 's4'],
87 'transaction should have new store in scope');
88 assert_array_equals(db2.objectStoreNames, tx2.objectStoreNames,
89 'connection and transacton objectStoreNames should match');
90
91 assert_array_equals(saved_tx.objectStoreNames, ['s2', 's3'],
92 'previous transaction objectStoreNames should be unchanged');
93 assert_array_equals(db.objectStoreNames, saved_tx.objectStoreNames,
94 'connection and transaction objectStoreNames should match');
95 t.done();
96 });
97 }, 'IDBTransaction.objectStoreNames - value after close');
98 }());
99
100 with_stores_test(['s1', 's2'], function(t, db) {
101 assert_array_equals(db.transaction('s1').objectStoreNames, ['s1'],
102 'transaction should have one store in scope');
103 assert_array_equals(db.transaction(['s1', 's2']).objectStoreNames,
104 ['s1', 's2'],
105 'transaction should have two stores in scope');
106 t.done();
107 }, 'IDBTransaction.objectStoreNames - transaction scope');
108
109 with_stores_test(['s1', 's2'], function(t, db) {
110 var tx = db.transaction(['s1', 's2'], 'readwrite');
111 tx.objectStore('s1').put(0, 0);
112 tx.onabort = t.unreached_func('transaction should complete');
113 tx.oncomplete = t.step_func(function() {
114 assert_array_equals(tx.objectStoreNames, ['s1', 's2'],
115 'objectStoreNames should return scope after transaction commits');
116 t.done();
117 });
118 }, 'IDBTransaction.objectStoreNames - value after commit');
119
120 with_stores_test(['s1', 's2'], function(t, db) {
121 var tx = db.transaction(['s1', 's2'], 'readwrite');
122 tx.objectStore('s1').put(0, 0);
123 tx.objectStore('s1').add(0, 0);
124 tx.oncomplete = t.unreached_func('transaction should abort');
125 tx.onabort = t.step_func(function() {
126 assert_array_equals(tx.objectStoreNames, ['s1', 's2'],
127 'objectStoreNames should return scope after transaction aborts');
128 t.done();
129 });
130 }, 'IDBTransaction.objectStoreNames - value after abort');
131
132 with_stores_test(['s1', 's2', 's3'], function(t, db) {
133 assert_array_equals(db.transaction(['s3', 's2', 's1']).objectStoreNames,
134 ['s1', 's2', 's3'],
135 'transaction objectStoreNames should be sorted');
136 t.done();
137 }, 'IDBTransaction.objectStoreNames - sorting');
138
139 with_stores_test(['s1', 's2'], function(t, db) {
140 assert_array_equals(
141 db.transaction(['s2', 's1', 's2']).objectStoreNames,
142 ['s1', 's2'],
143 'transaction objectStoreNames should not have duplicates');
144 t.done();
145 }, 'IDBTransaction.objectStoreNames - no duplicates');
146
147 var unusual_names = [
148 '', // empty string
149
150 '\x00', // U+0000 NULL
151 '\xFF', // U+00FF LATIN SMALL LETTER Y WITH DIAERESIS
152
153 '1', // basic ASCII
154 '12', // basic ASCII
155 '123', // basic ASCII
156 'abc', // basic ASCII
157 'ABC', // basic ASCII
158
159 '\xA2', // U+00A2 CENT SIGN
160 '\u6C34', // U+6C34 CJK UNIFIED IDEOGRAPH (water)
161 '\uD834\uDD1E', // U+1D11E MUSICAL SYMBOL G-CLEF (UTF-16 surrogate pair)
162 '\uFFFD', // U+FFFD REPLACEMENT CHARACTER
163
164 '\uD800', // UTF-16 surrogate lead
165 '\uDC00', // UTF-16 surrogate trail
166 ];
167 unusual_names.sort();
168
169 indexeddb_test(function(t, db, tx) {
170 unusual_names.slice().reverse().forEach(function(name) {
171 db.createObjectStore(name);
172 });
173 assert_array_equals(tx.objectStoreNames, unusual_names,
174 'transaction should have names sorted');
175 }, function(t, db) {
176 var tx = db.transaction(unusual_names.slice().reverse().concat(unusual_names ));
177 assert_array_equals(tx.objectStoreNames, unusual_names,
178 'transaction should have names sorted with no duplicates');
179 t.done();
180 }, 'IDBTransaction.objectStoreNames - unusual names');
181
182 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698