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

Side by Side Diff: LayoutTests/storage/indexeddb/bindings-edges.html

Issue 1154873007: IndexedDB: Rethrow exceptions thrown by getters during keypath eval (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move context out of loop Created 5 years, 6 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
« no previous file with comments | « no previous file | Source/bindings/modules/v8/V8BindingForModules.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>IndexedDB: Verify bindings edge cases</title> 2 <title>IndexedDB: Verify bindings edge cases</title>
3 <script src="../../resources/testharness.js"></script> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="resources/testharness-helpers.js"></script> 5 <script src="resources/testharness-helpers.js"></script>
6 <script> 6 <script>
7 indexeddb_test( 7 indexeddb_test(
8 function(t, db) { 8 function(t, db) {
9 db.createObjectStore('store'); 9 db.createObjectStore('store');
10 }, 10 },
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 request.onsuccess = t.step_func(function() { 153 request.onsuccess = t.step_func(function() {
154 var result = request.result; 154 var result = request.result;
155 assert_key_equals(result[testcase.property], key, 155 assert_key_equals(result[testcase.property], key,
156 'Property should be used as key'); 156 'Property should be used as key');
157 t.done(); 157 t.done();
158 }); 158 });
159 }, 159 },
160 'Type: ' + testcase.type + ', implicit property: ' + testcase.property 160 'Type: ' + testcase.type + ', implicit property: ' + testcase.property
161 ); 161 );
162 }); 162 });
163
164 function throws(name) {
165 return function() {
166 var err = Error();
167 err.name = name;
168 throw err;
169 }
170 }
171
172 indexeddb_test(
173 function(t, db) {
174 var o = {};
175 Object.defineProperty(o, 'throws', {get: throws('getter'),
176 enumerable: false, configurable: true});
177
178 // Value should be cloned before key path is evaluated,
179 // and non-enumerable getter will be ignored. The clone
180 // will have no such property, so key path evaluation
181 // will fail.
182 var s1 = db.createObjectStore('s1',
183 {keyPath: 'throws'});
184 assert_throws('DataError', function() {
185 s1.put(o);
186 }, 'Key path failing to resolve should throw');
187
188 // Value should be cloned before key path is evaluated,
189 // and non-enumerable getter will be ignored. The clone
190 // will have no such property, so key path evaluation
191 // will fail.
192 var s2 = db.createObjectStore('s2',
193 {keyPath: 'throws.x'});
194 assert_throws('DataError', function() {
195 s2.put(o);
196 }, 'Key path failing to resolve should throw');
197
198 // Value should be cloned before key path is evaluated,
199 // and non-enumerable getter will be ignored. The clone
200 // will have no such property, so generated key can be
201 // inserted.
202 var s3 = db.createObjectStore('s3',
203 {keyPath: 'throws', autoIncrement: true});
204 assert_class_string(s3.put(o), 'IDBRequest',
205 'Key injectability test at throwing getter should succeed');
206
207 // Value should be cloned before key path is evaluated,
208 // and non-enumerable getter will be ignored. The clone
209 // will have no such property, so intermediate object
210 // and generated key can be inserted.
211 var s4 = db.createObjectStore('s4',
212 {keyPath: 'throws.x', autoIncrement: true});
213 assert_class_string(s4.put(o), 'IDBRequest',
214 'Key injectability test past throwing getter should succeed');
215 },
216 function(t, db) {
217 t.done();
218 },
219 'Key path evaluation: Exceptions from non-enumerable getters'
220 );
221
222 indexeddb_test(
223 function(t, db) {
224 var o = {};
225 Object.defineProperty(o, 'throws', {get: throws('getter'),
226 enumerable: true, configurable: true});
227
228 // Value should be cloned before key path is evaluated,
229 // and enumerable getter will rethrow.
230 var s1 = db.createObjectStore('s1',
231 {keyPath: 'throws'});
232 assert_throws({name: 'getter'}, function() {
233 s1.put(o);
234 }, 'Key path resolving to throwing getter rethrows');
235
236 // Value should be cloned before key path is evaluated,
237 // and enumerable getter will rethrow.
238 var s2 = db.createObjectStore('s2',
239 {keyPath: 'throws.x'});
240 assert_throws({name: 'getter'}, function() {
241 s2.put(o);
242 }, 'Key path resolving past throwing getter rethrows');
243
244 // Value should be cloned before key path is evaluated,
245 // and enumerable getter will rethrow.
246 var s3 = db.createObjectStore('s3',
247 {keyPath: 'throws', autoIncrement: true});
248 assert_throws({name: 'getter'}, function() {
249 s3.put(o);
250 }, 'Key injectability test at throwing getter should rethrow');
251
252 // Value should be cloned before key path is evaluated,
253 // and enumerable getter will rethrow.
254 var s4 = db.createObjectStore('s4',
255 {keyPath: 'throws.x', autoIncrement: true});
256 assert_throws({name: 'getter'}, function() {
257 s4.put(o);
258 }, 'Key injectability test past throwing getter should rethrow');
259 },
260 function(t, db) {
261 t.done();
262 },
263 'Key path evaluation: Exceptions from enumerable getters'
264 );
265
266 indexeddb_test(
267 function(t, db) {
268 // Implemented as function wrapper to clean up
269 // immediately after use, otherwise it may
270 // interfere with the test harness.
271 function with_proto_getter(f) {
272 return function() {
273 Object.defineProperty(Object.prototype, 'throws', {
274 get: throws('getter'),
275 enumerable: false, configurable: true
276 });
277 try {
278 f();
279 } finally {
280 delete Object.prototype['throws'];
281 }
282 };
283 }
284
285 // Value should be cloned before key path is evaluated,
286 // and non-enumerable getter will be ignored. The clone
287 // will have no such property, so key path evaluation
288 // will hit prototype property and rethrow.
289 var s1 = db.createObjectStore('s1',
290 {keyPath: 'throws'});
291 assert_throws({name: 'getter'}, with_proto_getter(function() {
292 s1.put({});
293 }), 'Key path resolving to throwing getter rethrows');
294
295 // Value should be cloned before key path is evaluated,
296 // and non-enumerable getter will be ignored. The clone
297 // will have no such property, so key path evaluation
298 // will hit prototype property and rethrow.
299 var s2 = db.createObjectStore('s2',
300 {keyPath: 'throws.x'});
301 assert_throws({name: 'getter'}, with_proto_getter(function() {
302 s2.put({});
303 }), 'Key path resolving past throwing getter rethrows');
304
305 // Value should be cloned before key path is evaluated,
306 // and non-enumerable getter will be ignored. The clone
307 // will have no such property, so key path evaluation
308 // will hit prototype property and rethrow.
309 var s3 = db.createObjectStore('s3',
310 {keyPath: 'throws', autoIncrement: true});
311 assert_throws({name: 'getter'}, with_proto_getter(function() {
312 s3.put({});
313 }), 'Key injectability test at throwing getter rethrows');
314
315 // Value should be cloned before key path is evaluated,
316 // and non-enumerable getter will be ignored. The clone
317 // will have no such property, so key path evaluation
318 // will hit prototype property and rethrow.
319 var s4 = db.createObjectStore('s4',
320 {keyPath: 'throws.x', autoIncrement: true});
321 assert_throws({name: 'getter'}, with_proto_getter(function() {
322 s4.put({});
323 }), 'Key injectability test past throwing getter rethrows');
324 },
325 function(t, db) {
326 t.done();
327 },
328 'Key path evaluation: Exceptions from non-enumerable getters on prototype'
329 );
330
331 indexeddb_test(
332 function(t, db) {
333 // Implemented as function wrapper to clean up
334 // immediately after use, otherwise it may
335 // interfere with the test harness.
336 function with_proto_getter(f) {
337 return function() {
338 Object.defineProperty(Object.prototype, 'throws', {
339 get: throws('getter'),
340 enumerable: true, configurable: true
341 });
342 try {
343 f();
344 } finally {
345 delete Object.prototype['throws'];
346 }
347 };
348 }
349
350 // Value should be cloned before key path is evaluated,
351 // and enumerable getter will rethrow.
352 var s1 = db.createObjectStore('s1',
353 {keyPath: 'throws'});
354 assert_throws({name: 'getter'}, with_proto_getter(function() {
355 s1.put({});
356 }), 'Key path resolving to throwing getter rethrows');
357
358 // Value should be cloned before key path is evaluated,
359 // and enumerable getter will rethrow.
360 var s2 = db.createObjectStore('s2',
361 {keyPath: 'throws.x'});
362 assert_throws({name: 'getter'}, with_proto_getter(function() {
363 s2.put({});
364 }), 'Key path resolving past throwing getter rethrows');
365
366 // Value should be cloned before key path is evaluated,
367 // and enumerable getter will rethrow.
368 var s3 = db.createObjectStore('s3',
369 {keyPath: 'throws', autoIncrement: true});
370 assert_throws({name: 'getter'}, with_proto_getter(function() {
371 s3.put({});
372 }), 'Key injectability test at throwing getter rethrows');
373
374 // Value should be cloned before key path is evaluated,
375 // and enumerable getter will rethrow.
376 var s4 = db.createObjectStore('s4',
377 {keyPath: 'throws.x', autoIncrement: true});
378 assert_throws({name: 'getter'}, with_proto_getter(function() {
379 s4.put({});
380 }), 'Key injectability test past throwing getter rethrows');
381 },
382 function(t, db) {
383 t.done();
384 },
385 'Key path evaluation: Exceptions from enumerable getters on prototype'
386 );
163 </script> 387 </script>
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/modules/v8/V8BindingForModules.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698