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

Unified Diff: src/v8natives.js

Issue 11312247: Modify Object.{freeze,seal,isFrozen,isSealed} to avoid the problematic "caller" method on Functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 | test/mjsunit/regress/regress-2407.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 20fc74dc440dcf28dd64ece1de30133611aadf0b..7c8381812bb86158ad554bd6e774f42cab974eb5 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1154,6 +1154,17 @@ function ProxyFix(obj) {
ObjectDefineProperties(obj, props);
}
+function GetOwnPropertyNamesForSealOrFreeze(obj) {
+ var names = ObjectGetOwnPropertyNames(obj);
+ if (IS_SPEC_FUNCTION(obj)) {
rossberg 2012/11/16 12:28:55 IS_FUNCTION probably is more adequate here, since
arv (Not doing code reviews) 2012/11/16 14:38:06 There are more poison pills than functionObj.calle
rossberg 2012/11/16 15:52:46 Yes, but this issue affects only "caller", because
+ // The "caller" property on Functions is always non-writable and
+ // non-configurable, so there's no need to check it or redefine it.
+ // Thus, we skip it to avoid the strict-mode check the getter enforces.
+ names = names.filter(function(name) { return name != "caller"; });
+ }
+ return names;
+}
+
// ES5 section 15.2.3.8.
function ObjectSeal(obj) {
@@ -1163,7 +1174,7 @@ function ObjectSeal(obj) {
if (%IsJSProxy(obj)) {
ProxyFix(obj);
}
- var names = ObjectGetOwnPropertyNames(obj);
+ var names = GetOwnPropertyNamesForSealOrFreeze(obj);
for (var i = 0; i < names.length; i++) {
var name = names[i];
var desc = GetOwnProperty(obj, name);
@@ -1185,7 +1196,7 @@ function ObjectFreeze(obj) {
if (%IsJSProxy(obj)) {
ProxyFix(obj);
}
- var names = ObjectGetOwnPropertyNames(obj);
+ var names = GetOwnPropertyNamesForSealOrFreeze(obj);
for (var i = 0; i < names.length; i++) {
var name = names[i];
var desc = GetOwnProperty(obj, name);
@@ -1221,7 +1232,7 @@ function ObjectIsSealed(obj) {
if (%IsJSProxy(obj)) {
return false;
}
- var names = ObjectGetOwnPropertyNames(obj);
+ var names = GetOwnPropertyNamesForSealOrFreeze(obj);
for (var i = 0; i < names.length; i++) {
var name = names[i];
var desc = GetOwnProperty(obj, name);
@@ -1242,7 +1253,7 @@ function ObjectIsFrozen(obj) {
if (%IsJSProxy(obj)) {
return false;
}
- var names = ObjectGetOwnPropertyNames(obj);
+ var names = GetOwnPropertyNamesForSealOrFreeze(obj);
for (var i = 0; i < names.length; i++) {
var name = names[i];
var desc = GetOwnProperty(obj, name);
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-2407.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698