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

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-continue.htm

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>IDBCursor.continue()</title>
3 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
4 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html# widl-IDBCursor-continue-void-any-key">
5 <link rel=assert title="The next key to position this cursor at">
6 <script src="../../../resources/testharness.js"></script>
7 <script src="../../../resources/testharnessreport.js"></script>
8 <script src="support.js"></script>
9
10 <script>
11
12 var db, open;
13 var store = [ { value: "cupcake", key: 5 },
14 { value: "pancake", key: 3 },
15 { value: "pie", key: 1 },
16 { value: "pie", key: 4 },
17 { value: "taco", key: 2 } ];
18
19 setup(function() {
20 open = indexedDB.open('testdb-' + new Date().getTime());
21 open.onupgradeneeded = function(e) {
22 var os, i;
23 db = e.target.result;
24 os = db.createObjectStore("test");
25 os.createIndex("index", "");
26
27 for (i = 0; i < store.length; i++)
28 os.add(store[i].value, store[i].key);
29 };
30 },
31 { explicit_done: true });
32
33
34 open.onsuccess = function() {
35
36
37 async_test(document.title + " - continues").step(function(e) {
38 var count = 0;
39 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
40
41 rq.onsuccess = this.step_func(function(e) {
42 if (!e.target.result) {
43 assert_equals(count, 5, 'count');
44 this.done();
45 return;
46 }
47 var cursor = e.target.result;
48
49 assert_equals(cursor.value, store[count].value);
50 assert_equals(cursor.primaryKey, store[count].key);
51
52 cursor.continue();
53
54 count++;
55 });
56 rq.onerror = fail(this, "unexpected error")
57 });
58
59
60 async_test(document.title + " - with given key").step(function(e) {
61 var count = 0;
62 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
63
64 rq.onsuccess = this.step_func(function(e) {
65 if (!e.target.result) {
66 assert_equals(count, 3, 'count');
67 this.done();
68 return;
69 }
70 var cursor = e.target.result;
71
72 switch(count) {
73 case 0:
74 assert_equals(cursor.value, "cupcake");
75 assert_equals(cursor.primaryKey, 5);
76 cursor.continue("pie");
77 break;
78
79 case 1:
80 assert_equals(cursor.value, "pie");
81 assert_equals(cursor.primaryKey, 1);
82 cursor.continue("taco");
83 break;
84
85 case 2:
86 assert_equals(cursor.value, "taco");
87 assert_equals(cursor.primaryKey, 2);
88 cursor.continue();
89 break;
90
91 default:
92 assert_unreached("Unexpected count: " + count);
93 }
94
95 count++;
96 });
97 rq.onerror = fail(this, "unexpected error")
98 });
99
100
101 async_test(document.title + " - skip far forward").step(function(e) {
102 var count = 0;
103 var rq = db.transaction("test").objectStore("test").index("index")
104 .openCursor();
105
106 rq.onsuccess = this.step_func(function(e) {
107 if (!e.target.result) {
108 assert_equals(count, 1, 'count');
109 this.done();
110 return;
111 }
112 var cursor = e.target.result;
113
114 switch(count) {
115 case 0:
116 assert_equals(cursor.value, "cupcake");
117 assert_equals(cursor.primaryKey, 5);
118 break;
119
120 default:
121 assert_unreached("Unexpected count: " + count);
122 }
123
124 count++;
125 cursor.continue([]); // Arrays are always bigger than strings
126
127 });
128 rq.onerror = fail(this, "unexpected error2")
129 });
130
131
132 async_test(document.title + " - within range").step(function(e) {
133 var count = 0;
134 var rq = db.transaction("test").objectStore("test").index("index")
135 .openCursor(IDBKeyRange.lowerBound("cupcake", true));
136
137 rq.onsuccess = this.step_func(function(e) {
138 if (!e.target.result) {
139 assert_equals(count, 2, 'count');
140 this.done();
141 return;
142 }
143 var cursor = e.target.result;
144
145 switch(count) {
146 case 0:
147 assert_equals(cursor.value, "pancake");
148 assert_equals(cursor.primaryKey, 3);
149 cursor.continue("pie");
150 break;
151
152 case 1:
153 assert_equals(cursor.value, "pie");
154 assert_equals(cursor.primaryKey, 1);
155 cursor.continue("zzz");
156 break;
157
158 default:
159 assert_unreached("Unexpected count: " + count);
160 }
161
162 count++;
163 });
164 rq.onerror = fail(this, "unexpected error1")
165 });
166
167
168 async_test(document.title + " - within single key range").step(function( e) {
169 var count = 0;
170 var rq = db.transaction("test").objectStore("test").index("index")
171 .openCursor("pancake");
172
173 rq.onsuccess = this.step_func(function(e) {
174 if (!e.target.result) {
175 assert_equals(count, 1, 'count');
176 this.done();
177 return;
178 }
179 var cursor = e.target.result;
180
181 switch(count) {
182 case 0:
183 assert_equals(cursor.value, "pancake");
184 assert_equals(cursor.primaryKey, 3);
185 cursor.continue("pie");
186 break;
187
188 default:
189 assert_unreached("Unexpected count: " + count);
190 }
191
192 count++;
193 });
194 rq.onerror = fail(this, "unexpected error1")
195 });
196
197
198 async_test(document.title + " - within single key range, with several re sults").step(function(e) {
199 var count = 0;
200 var rq = db.transaction("test").objectStore("test").index("index")
201 .openCursor("pie");
202
203 rq.onsuccess = this.step_func(function(e) {
204 if (!e.target.result) {
205 assert_equals(count, 2, 'count');
206 this.done();
207 return;
208 }
209 var cursor = e.target.result;
210
211 switch(count) {
212 case 0:
213 assert_equals(cursor.value, "pie");
214 assert_equals(cursor.primaryKey, 1);
215 cursor.continue();
216 break;
217
218 case 1:
219 assert_equals(cursor.value, "pie");
220 assert_equals(cursor.primaryKey, 4);
221 cursor.continue();
222 break;
223
224 default:
225 assert_unreached("Unexpected count: " + count);
226 }
227
228 count++;
229 });
230 rq.onerror = fail(this, "unexpected error1")
231 });
232
233
234 // Stop blocking the testing system from hereon
235 done();
236 }
237
238 </script>
239
240 <div id="log"></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698