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

Unified Diff: test/mjsunit/harmony/object-observe.js

Issue 116083006: Make Function.length and Function.name configurable properties. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Improve test changes somewhat Created 6 years, 11 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 | « test/cctest/test-accessors.cc ('k') | test/mjsunit/regress/regress-1530.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/object-observe.js
diff --git a/test/mjsunit/harmony/object-observe.js b/test/mjsunit/harmony/object-observe.js
index 72a9cadbf8ecb9df05a37593055e58e3c44f7efc..56c0fe4565f56fe2c4669e7e9db1e0d88d849dc2 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -975,16 +975,39 @@ observer.assertNotCalled();
// Test all kinds of objects generically.
-function TestObserveConfigurable(obj, prop) {
+function TestObserveConfigurable(obj, prop, is_writable) {
reset();
+ var valueWhenDeleted = is_writable ? 3 : obj[prop];
Object.observe(obj, observer.callback);
Object.unobserve(obj, observer.callback);
obj[prop] = 1;
Object.observe(obj, observer.callback);
obj[prop] = 2;
- obj[prop] = 3;
+ obj[prop] = valueWhenDeleted;
delete obj[prop];
- obj[prop] = 4;
+ // If the deleted obj[prop] exposed another 'prop' along the
+ // prototype chain, only update it if it has compatible attributes.
rossberg 2014/01/09 14:59:35 This comment seems misleading. You never update th
+ // If not, create an own property with the descriptor that [[Put]]
+ // mandates for a new property (ES-5.1, 8.12.5.6)
+ var createOwnProperty = false;
+ for (var o = Object.getPrototypeOf(obj); o; o = Object.getPrototypeOf(o)) {
+ var desc = Object.getOwnPropertyDescriptor(o, prop);
+ if (desc) {
+ // Have to be able to re-configure and update the property.
+ if (!desc.configurable || !desc.writable || desc.set)
rossberg 2014/01/09 14:59:35 I think this should be more like if (!desc.writ
+ createOwnProperty = true;
+ break;
+ }
+ }
+ if (createOwnProperty)
+ Object.defineProperty(obj, prop, {
+ value: 4,
+ writable: true,
+ enumerable: true,
+ configurable: true
+ });
+ else
+ obj[prop] = 4;
obj[prop] = 4; // ignored
obj[prop] = 5;
Object.defineProperty(obj, prop, {value: 6});
@@ -1014,10 +1037,9 @@ function TestObserveConfigurable(obj, prop) {
delete obj[prop];
Object.defineProperty(obj, prop, {value: 11, configurable: true});
Object.deliverChangeRecords(observer.callback);
- observer.assertCallbackRecords([
- { object: obj, name: prop, type: "update", oldValue: 1 },
- { object: obj, name: prop, type: "update", oldValue: 2 },
- { object: obj, name: prop, type: "delete", oldValue: 3 },
+
+ var expected = [
+ { object: obj, name: prop, type: "delete", oldValue: valueWhenDeleted },
{ object: obj, name: prop, type: "add" },
{ object: obj, name: prop, type: "update", oldValue: 4 },
{ object: obj, name: prop, type: "update", oldValue: 5 },
@@ -1041,7 +1063,15 @@ function TestObserveConfigurable(obj, prop) {
{ object: obj, name: prop, type: "update", oldValue: 12 },
{ object: obj, name: prop, type: "delete", oldValue: 36 },
{ object: obj, name: prop, type: "add" },
- ]);
+ ];
+
+ if (is_writable) {
+ expected.unshift(
+ { object: obj, name: prop, type: "update", oldValue: 1 },
+ { object: obj, name: prop, type: "update", oldValue: 2 });
+ }
+
+ observer.assertCallbackRecords(expected);
Object.unobserve(obj, observer.callback);
delete obj[prop];
}
@@ -1143,7 +1173,7 @@ for (var i in objects) for (var j in properties) {
var desc = Object.getOwnPropertyDescriptor(obj, prop);
print("***", typeof obj, stringifyNoThrow(obj), prop);
if (!desc || desc.configurable)
- TestObserveConfigurable(obj, prop);
+ TestObserveConfigurable(obj, prop, !desc || desc.writable);
else if (desc.writable)
TestObserveNonConfigurable(obj, prop, desc);
}
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/mjsunit/regress/regress-1530.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698