Skip to content

Commit

Permalink
Merge pull request #52 from RReverser/defineproperty-result
Browse files Browse the repository at this point in the history
Fix patched Object.defineProperty to return proxy itself.
  • Loading branch information
tvcutsem committed May 27, 2015
2 parents 2747604 + 5f680bf commit ae423a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion reflect.js
Expand Up @@ -1437,7 +1437,7 @@ Object.defineProperty = function(subject, name, desc) {
if (success === false) {
throw new TypeError("can't redefine property '"+name+"'");
}
return success;
return subject;
} else {
return prim_defineProperty(subject, name, desc);
}
Expand Down
12 changes: 12 additions & 0 deletions test/testProxies.js
Expand Up @@ -325,6 +325,18 @@ load('../reflect.js');
});
};

TESTS.testDefinePropertyReturnsProxy =
function(brokenProxy, emulatedProps, emulatedProto, success) {
success.x = true;
var result = Object.defineProperty(brokenProxy,'x',{
value: 2,
writable: true,
enumerable: true,
configurable: true
});
assert(result === brokenProxy, 'patched defineProperty returns proxy');
};

TESTS.testNonConfigurableNoDelete =
function(brokenProxy, emulatedProps, emulatedProto, success, target) {
emulatedProps.x = {value:1, configurable:false};
Expand Down

0 comments on commit ae423a4

Please sign in to comment.