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

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

Issue 2332003002: IndexedDB: Avoid side effects for array key conversion w/ HasOwnProperty (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | third_party/WebKit/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 },
11 function(t, db) { 11 function(t, db) {
12 var tx = db.transaction('store', 'readwrite'); 12 var tx = db.transaction('store', 'readwrite');
13 var request = tx.objectStore('store').put('value', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'key']); 13 var request = tx.objectStore('store').put('value', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'key']);
14 14
15 var setter_called = false; 15 var setter_called = false;
16 Object.defineProperty(Object.prototype, '10', { 16 Object.defineProperty(Object.prototype, '10', {
17 configurable: true,
17 set: t.step_func(function(value) { setter_called = true; }) 18 set: t.step_func(function(value) { setter_called = true; })
18 }); 19 });
19 request.onerror = t.unreached_func('request should not fail'); 20 request.onerror = t.unreached_func('request should not fail');
20 request.onsuccess = t.step_func(function() { 21 request.onsuccess = t.step_func(function() {
21 var result = request.result; 22 var result = request.result;
22 assert_false(setter_called, 23 assert_false(setter_called,
23 'Setter should not be called for key result.'); 24 'Setter should not be called for key result.');
24 assert_true(result.hasOwnProperty('10'), 25 assert_true(result.hasOwnProperty('10'),
25 'Result should have own-property overriding prototype se tter.'); 26 'Result should have own-property overriding prototype se tter.');
26 assert_equals(result[10], 'key', 27 assert_equals(result[10], 'key',
27 'Result should have expected property.'); 28 'Result should have expected property.');
29
30 delete Object.prototype['10'];
28 t.done(); 31 t.done();
29 }); 32 });
30 }, 33 },
31 'Returning keys to script should bypass prototype setters' 34 'Returning keys to script should bypass prototype setters'
32 ); 35 );
33 36
34 indexeddb_test( 37 indexeddb_test(
35 function(t, db) { 38 function(t, db) {
36 db.createObjectStore('store', {autoIncrement: true, keyPath: 'id'}); 39 db.createObjectStore('store', {autoIncrement: true, keyPath: 'id'});
37 }, 40 },
38 function(t, db) { 41 function(t, db) {
39 var tx = db.transaction('store', 'readwrite'); 42 var tx = db.transaction('store', 'readwrite');
40 tx.objectStore('store').put({}); 43 tx.objectStore('store').put({});
41 var request = tx.objectStore('store').get(1); 44 var request = tx.objectStore('store').get(1);
42 45
43 var setter_called = false; 46 var setter_called = false;
44 Object.defineProperty(Object.prototype, 'id', { 47 Object.defineProperty(Object.prototype, 'id', {
48 configurable: true,
45 set: t.step_func(function(value) { setter_called = true; }) 49 set: t.step_func(function(value) { setter_called = true; })
46 }); 50 });
47 request.onerror = t.unreached_func('request should not fail'); 51 request.onerror = t.unreached_func('request should not fail');
48 request.onsuccess = t.step_func(function() { 52 request.onsuccess = t.step_func(function() {
49 var result = request.result; 53 var result = request.result;
50 assert_false(setter_called, 54 assert_false(setter_called,
51 'Setter should not be called for key result.'); 55 'Setter should not be called for key result.');
52 assert_true(result.hasOwnProperty('id'), 56 assert_true(result.hasOwnProperty('id'),
53 'Result should have own-property overriding prototype se tter.'); 57 'Result should have own-property overriding prototype se tter.');
54 assert_equals(result.id, 1, 58 assert_equals(result.id, 1,
55 'Own property should match primary key generator value '); 59 'Own property should match primary key generator value ');
60
61 delete Object.prototype['id'];
56 t.done(); 62 t.done();
57 }); 63 });
58 }, 64 },
59 'Returning values to script should bypass prototype setters' 65 'Returning values to script should bypass prototype setters'
60 ); 66 );
61 67
62 indexeddb_test( 68 indexeddb_test(
63 function(t, db) { 69 function(t, db) {
64 db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.c'}); 70 db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.c'});
65 }, 71 },
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 var s4 = db.createObjectStore('s4', 383 var s4 = db.createObjectStore('s4',
378 {keyPath: 'throws.x', autoIncrement: true}); 384 {keyPath: 'throws.x', autoIncrement: true});
379 assert_equals(s4.put({}).readyState, 'pending', 385 assert_equals(s4.put({}).readyState, 'pending',
380 'put should not throw due to inherited property'); 386 'put should not throw due to inherited property');
381 }, 387 },
382 function(t, db) { 388 function(t, db) {
383 t.done(); 389 t.done();
384 }, 390 },
385 'Key path evaluation: Exceptions from enumerable getters on prototype' 391 'Key path evaluation: Exceptions from enumerable getters on prototype'
386 ); 392 );
393
394 indexeddb_test(
395 function(t, db) {
396 var store = db.createObjectStore('store');
397 store.createIndex('index', 'index0');
398 },
399 function(t, db) {
400 var tx = db.transaction('store', 'readwrite');
401
402 var array = [];
403 array[99] = 1;
404
405 var getter_called = 0;
406 var prop = '50';
407 Object.defineProperty(Object.prototype, prop, {
408 enumerable: true, configurable: true,
409 get: function() {
410 ++getter_called;
411 return 'foo';
412 }
413 });
414
415 var request = tx.objectStore('store').put({index0: array}, 'key');
416 request.onerror = t.unreached_func('put should not fail');
417 request.onsuccess = t.step_func(function() {
418 assert_equals(getter_called, 0,
419 'Prototype getter should not be called');
420 delete Object.prototype[prop];
421 t.done();
422 });
423 },
424 'Array key conversion should not invoke prototype getters'
425 );
426
387 </script> 427 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698