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

Unified Diff: src/runtime.cc

Issue 8996008: Fix handling of foreign callbacks in DefineOwnProperty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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-1530.js » ('j') | test/mjsunit/regress/regress-1530.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index b0e1a057da4b4384cedff7372fd0a04775c14988..09c1a1b88da4d9b3fc4af7595b70705747289c8d 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4326,12 +4326,25 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
LookupResult result(isolate);
js_object->LocalLookupRealNamedProperty(*name, &result);
- // To be compatible with safari we do not change the value on API objects
- // in defineProperty. Firefox disagrees here, and actually changes the value.
- if (result.IsProperty() &&
- (result.type() == CALLBACKS) &&
- result.GetCallbackObject()->IsAccessorInfo()) {
- return isolate->heap()->undefined_value();
+ // Special case for callback properties.
+ if (result.IsProperty() && result.type() == CALLBACKS) {
+ Object* callback = result.GetCallbackObject();
+ // To be compatible with safari we do not change the value on API objects
+ // in defineProperty. Firefox disagrees here, and actually changes the value.
rossberg 2011/12/19 16:47:44 80 characters
Michael Starzinger 2011/12/20 08:50:16 Done.
+ if (callback->IsAccessorInfo()) {
+ return isolate->heap()->undefined_value();
+ }
+ // Avoid redefining foreign callback as data property, just use the stored
+ // setter to update the value instead.
+ // TODO(mstarzinger): So far this only works if property attributes don't
+ // change, this should be fixed once we cleanup the underlying code.
+ if (callback->IsForeign() && result.GetAttributes() == attr) {
+ return js_object->SetPropertyWithCallback(callback,
+ *name,
+ *obj_value,
+ result.holder(),
+ kNonStrictMode);
rossberg 2011/12/19 16:47:44 This should be KStrictMode, I think.
Michael Starzinger 2011/12/20 08:50:16 Done. On this code path it doesn't actually matter
+ }
}
// Take special care when attributes are different and there is already
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1530.js » ('j') | test/mjsunit/regress/regress-1530.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698