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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/modules/v8/V8BindingForModules.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/storage/indexeddb/bindings-edges.html
diff --git a/LayoutTests/storage/indexeddb/bindings-edges.html b/LayoutTests/storage/indexeddb/bindings-edges.html
index 3e726e7000eacbfc33fc6b31eb476ba8365c449c..252179157e8463e8b0624ff037a50a8a266a02cb 100644
--- a/LayoutTests/storage/indexeddb/bindings-edges.html
+++ b/LayoutTests/storage/indexeddb/bindings-edges.html
@@ -160,4 +160,228 @@ indexeddb_test(
'Type: ' + testcase.type + ', implicit property: ' + testcase.property
);
});
+
+function throws(name) {
+ return function() {
+ var err = Error();
+ err.name = name;
+ throw err;
+ }
+}
+
+indexeddb_test(
+ function(t, db) {
+ var o = {};
+ Object.defineProperty(o, 'throws', {get: throws('getter'),
+ enumerable: false, configurable: true});
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so key path evaluation
+ // will fail.
+ var s1 = db.createObjectStore('s1',
+ {keyPath: 'throws'});
+ assert_throws('DataError', function() {
+ s1.put(o);
+ }, 'Key path failing to resolve should throw');
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so key path evaluation
+ // will fail.
+ var s2 = db.createObjectStore('s2',
+ {keyPath: 'throws.x'});
+ assert_throws('DataError', function() {
+ s2.put(o);
+ }, 'Key path failing to resolve should throw');
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so generated key can be
+ // inserted.
+ var s3 = db.createObjectStore('s3',
+ {keyPath: 'throws', autoIncrement: true});
+ assert_class_string(s3.put(o), 'IDBRequest',
+ 'Key injectability test at throwing getter should succeed');
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so intermediate object
+ // and generated key can be inserted.
+ var s4 = db.createObjectStore('s4',
+ {keyPath: 'throws.x', autoIncrement: true});
+ assert_class_string(s4.put(o), 'IDBRequest',
+ 'Key injectability test past throwing getter should succeed');
+ },
+ function(t, db) {
+ t.done();
+ },
+ 'Key path evaluation: Exceptions from non-enumerable getters'
+);
+
+indexeddb_test(
+ function(t, db) {
+ var o = {};
+ Object.defineProperty(o, 'throws', {get: throws('getter'),
+ enumerable: true, configurable: true});
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s1 = db.createObjectStore('s1',
+ {keyPath: 'throws'});
+ assert_throws({name: 'getter'}, function() {
+ s1.put(o);
+ }, 'Key path resolving to throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s2 = db.createObjectStore('s2',
+ {keyPath: 'throws.x'});
+ assert_throws({name: 'getter'}, function() {
+ s2.put(o);
+ }, 'Key path resolving past throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s3 = db.createObjectStore('s3',
+ {keyPath: 'throws', autoIncrement: true});
+ assert_throws({name: 'getter'}, function() {
+ s3.put(o);
+ }, 'Key injectability test at throwing getter should rethrow');
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s4 = db.createObjectStore('s4',
+ {keyPath: 'throws.x', autoIncrement: true});
+ assert_throws({name: 'getter'}, function() {
+ s4.put(o);
+ }, 'Key injectability test past throwing getter should rethrow');
+ },
+ function(t, db) {
+ t.done();
+ },
+ 'Key path evaluation: Exceptions from enumerable getters'
+);
+
+indexeddb_test(
+ function(t, db) {
+ // Implemented as function wrapper to clean up
+ // immediately after use, otherwise it may
+ // interfere with the test harness.
+ function with_proto_getter(f) {
+ return function() {
+ Object.defineProperty(Object.prototype, 'throws', {
+ get: throws('getter'),
+ enumerable: false, configurable: true
+ });
+ try {
+ f();
+ } finally {
+ delete Object.prototype['throws'];
+ }
+ };
+ }
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so key path evaluation
+ // will hit prototype property and rethrow.
+ var s1 = db.createObjectStore('s1',
+ {keyPath: 'throws'});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s1.put({});
+ }), 'Key path resolving to throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so key path evaluation
+ // will hit prototype property and rethrow.
+ var s2 = db.createObjectStore('s2',
+ {keyPath: 'throws.x'});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s2.put({});
+ }), 'Key path resolving past throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so key path evaluation
+ // will hit prototype property and rethrow.
+ var s3 = db.createObjectStore('s3',
+ {keyPath: 'throws', autoIncrement: true});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s3.put({});
+ }), 'Key injectability test at throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and non-enumerable getter will be ignored. The clone
+ // will have no such property, so key path evaluation
+ // will hit prototype property and rethrow.
+ var s4 = db.createObjectStore('s4',
+ {keyPath: 'throws.x', autoIncrement: true});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s4.put({});
+ }), 'Key injectability test past throwing getter rethrows');
+ },
+ function(t, db) {
+ t.done();
+ },
+ 'Key path evaluation: Exceptions from non-enumerable getters on prototype'
+);
+
+indexeddb_test(
+ function(t, db) {
+ // Implemented as function wrapper to clean up
+ // immediately after use, otherwise it may
+ // interfere with the test harness.
+ function with_proto_getter(f) {
+ return function() {
+ Object.defineProperty(Object.prototype, 'throws', {
+ get: throws('getter'),
+ enumerable: true, configurable: true
+ });
+ try {
+ f();
+ } finally {
+ delete Object.prototype['throws'];
+ }
+ };
+ }
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s1 = db.createObjectStore('s1',
+ {keyPath: 'throws'});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s1.put({});
+ }), 'Key path resolving to throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s2 = db.createObjectStore('s2',
+ {keyPath: 'throws.x'});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s2.put({});
+ }), 'Key path resolving past throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s3 = db.createObjectStore('s3',
+ {keyPath: 'throws', autoIncrement: true});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s3.put({});
+ }), 'Key injectability test at throwing getter rethrows');
+
+ // Value should be cloned before key path is evaluated,
+ // and enumerable getter will rethrow.
+ var s4 = db.createObjectStore('s4',
+ {keyPath: 'throws.x', autoIncrement: true});
+ assert_throws({name: 'getter'}, with_proto_getter(function() {
+ s4.put({});
+ }), 'Key injectability test past throwing getter rethrows');
+ },
+ function(t, db) {
+ t.done();
+ },
+ 'Key path evaluation: Exceptions from enumerable getters on prototype'
+);
</script>
« 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