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

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

Issue 2255413004: IndexedDB: Avoid side effects by evaluating key paths w/ HasOwnProperty (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | third_party/WebKit/LayoutTests/storage/indexeddb/key_conversion_exceptions.html » ('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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 try { 277 try {
278 f(); 278 f();
279 } finally { 279 } finally {
280 delete Object.prototype['throws']; 280 delete Object.prototype['throws'];
281 } 281 }
282 }; 282 };
283 } 283 }
284 284
285 // Value should be cloned before key path is evaluated, 285 // Value should be cloned before key path is evaluated,
286 // and non-enumerable getter will be ignored. The clone 286 // and non-enumerable getter will be ignored. The clone
287 // will have no such property, so key path evaluation 287 // will have no own property, so key path evaluation will
288 // will hit prototype property and rethrow. 288 // fail and DataError should be thrown.
289 var s1 = db.createObjectStore('s1', 289 var s1 = db.createObjectStore('s1',
290 {keyPath: 'throws'}); 290 {keyPath: 'throws'});
291 assert_throws({name: 'getter'}, with_proto_getter(function() { 291 assert_throws('DataError', with_proto_getter(function() {
292 s1.put({}); 292 s1.put({});
293 }), 'Key path resolving to throwing getter rethrows'); 293 }), 'Key path resolving to no own property throws DataError');
294 294
295 // Value should be cloned before key path is evaluated, 295 // Value should be cloned before key path is evaluated,
296 // and non-enumerable getter will be ignored. The clone 296 // and non-enumerable getter will be ignored. The clone
297 // will have no such property, so key path evaluation 297 // will have no own property, so key path evaluation will
298 // will hit prototype property and rethrow. 298 // fail and DataError should be thrown.
299 var s2 = db.createObjectStore('s2', 299 var s2 = db.createObjectStore('s2',
300 {keyPath: 'throws.x'}); 300 {keyPath: 'throws.x'});
301 assert_throws({name: 'getter'}, with_proto_getter(function() { 301 assert_throws('DataError', with_proto_getter(function() {
302 s2.put({}); 302 s2.put({});
303 }), 'Key path resolving past throwing getter rethrows'); 303 }), 'Key path resolving past no own property throws DataError');
304 304
305 // Value should be cloned before key path is evaluated, 305 // Value should be cloned before key path is evaluated,
306 // and non-enumerable getter will be ignored. The clone 306 // and non-enumerable getter will be ignored. The clone
307 // will have no such property, so key path evaluation 307 // will have no own property, so key path evaluation will
308 // will hit prototype property and rethrow. 308 // fail and injection can succeed.
309 var s3 = db.createObjectStore('s3', 309 var s3 = db.createObjectStore('s3',
310 {keyPath: 'throws', autoIncrement: true}); 310 {keyPath: 'throws', autoIncrement: true});
311 assert_throws({name: 'getter'}, with_proto_getter(function() { 311 assert_equals(s3.put({}).readyState, 'pending',
312 s3.put({}); 312 'put should not throw due to inherited property');
313 }), 'Key injectability test at throwing getter rethrows');
314 313
315 // Value should be cloned before key path is evaluated, 314 // Value should be cloned before key path is evaluated,
316 // and non-enumerable getter will be ignored. The clone 315 // and non-enumerable getter will be ignored. The clone
317 // will have no such property, so key path evaluation 316 // will have no own property, so key path evaluation will
318 // will hit prototype property and rethrow. 317 // fail and injection can succeed.
319 var s4 = db.createObjectStore('s4', 318 var s4 = db.createObjectStore('s4',
320 {keyPath: 'throws.x', autoIncrement: true}); 319 {keyPath: 'throws.x', autoIncrement: true});
321 assert_throws({name: 'getter'}, with_proto_getter(function() { 320 assert_equals(s4.put({}).readyState, 'pending',
322 s4.put({}); 321 'put should not throw due to inherited property');
323 }), 'Key injectability test past throwing getter rethrows');
324 }, 322 },
325 function(t, db) { 323 function(t, db) {
326 t.done(); 324 t.done();
327 }, 325 },
328 'Key path evaluation: Exceptions from non-enumerable getters on prototype' 326 'Key path evaluation: Exceptions from non-enumerable getters on prototype'
329 ); 327 );
330 328
331 indexeddb_test( 329 indexeddb_test(
332 function(t, db) { 330 function(t, db) {
333 // Implemented as function wrapper to clean up 331 // Implemented as function wrapper to clean up
334 // immediately after use, otherwise it may 332 // immediately after use, otherwise it may
335 // interfere with the test harness. 333 // interfere with the test harness.
336 function with_proto_getter(f) { 334 function with_proto_getter(f) {
337 return function() { 335 return function() {
338 Object.defineProperty(Object.prototype, 'throws', { 336 Object.defineProperty(Object.prototype, 'throws', {
339 get: throws('getter'), 337 get: throws('getter'),
340 enumerable: true, configurable: true 338 enumerable: true, configurable: true
341 }); 339 });
342 try { 340 try {
343 f(); 341 f();
344 } finally { 342 } finally {
345 delete Object.prototype['throws']; 343 delete Object.prototype['throws'];
346 } 344 }
347 }; 345 };
348 } 346 }
349 347
350 // Value should be cloned before key path is evaluated, 348 // Value should be cloned before key path is evaluated.
351 // and enumerable getter will rethrow. 349 // The clone will have no own property, so key path
350 // evaluation will fail and DataError should be thrown.
352 var s1 = db.createObjectStore('s1', 351 var s1 = db.createObjectStore('s1',
353 {keyPath: 'throws'}); 352 {keyPath: 'throws'});
354 assert_throws({name: 'getter'}, with_proto_getter(function() { 353 assert_throws('DataError', with_proto_getter(function() {
355 s1.put({}); 354 s1.put({});
356 }), 'Key path resolving to throwing getter rethrows'); 355 }), 'Key path resolving to no own property throws DataError');
357 356
358 // Value should be cloned before key path is evaluated, 357 // Value should be cloned before key path is evaluated.
359 // and enumerable getter will rethrow. 358 // The clone will have no own property, so key path
359 // evaluation will fail and DataError should be thrown.
360 var s2 = db.createObjectStore('s2', 360 var s2 = db.createObjectStore('s2',
361 {keyPath: 'throws.x'}); 361 {keyPath: 'throws.x'});
362 assert_throws({name: 'getter'}, with_proto_getter(function() { 362 assert_throws('DataError', with_proto_getter(function() {
363 s2.put({}); 363 s2.put({});
364 }), 'Key path resolving past throwing getter rethrows'); 364 }), 'Key path resolving past throwing getter rethrows');
365 365
366 // Value should be cloned before key path is evaluated, 366 // Value should be cloned before key path is evaluated.
367 // and enumerable getter will rethrow. 367 // The clone will have no own property, so key path
368 // evaluation will fail and injection can succeed.
368 var s3 = db.createObjectStore('s3', 369 var s3 = db.createObjectStore('s3',
369 {keyPath: 'throws', autoIncrement: true}); 370 {keyPath: 'throws', autoIncrement: true});
370 assert_throws({name: 'getter'}, with_proto_getter(function() { 371 assert_equals(s3.put({}).readyState, 'pending',
371 s3.put({}); 372 'put should not throw due to inherited property');
372 }), 'Key injectability test at throwing getter rethrows');
373 373
374 // Value should be cloned before key path is evaluated, 374 // Value should be cloned before key path is evaluated.
375 // and enumerable getter will rethrow. 375 // The clone will have no own property, so key path
376 // evaluation will fail and injection can succeed.
376 var s4 = db.createObjectStore('s4', 377 var s4 = db.createObjectStore('s4',
377 {keyPath: 'throws.x', autoIncrement: true}); 378 {keyPath: 'throws.x', autoIncrement: true});
378 assert_throws({name: 'getter'}, with_proto_getter(function() { 379 assert_equals(s4.put({}).readyState, 'pending',
379 s4.put({}); 380 'put should not throw due to inherited property');
380 }), 'Key injectability test past throwing getter rethrows');
381 }, 381 },
382 function(t, db) { 382 function(t, db) {
383 t.done(); 383 t.done();
384 }, 384 },
385 'Key path evaluation: Exceptions from enumerable getters on prototype' 385 'Key path evaluation: Exceptions from enumerable getters on prototype'
386 ); 386 );
387 </script> 387 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/storage/indexeddb/key_conversion_exceptions.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698