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

Side by Side Diff: src/runtime.cc

Issue 240573004: Allow Object.defineProperty to update value of an API accessor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5211 matching lines...) Expand 10 before | Expand all | Expand 10 after
5222 !isolate->MayNamedAccess(js_object, name, v8::ACCESS_SET)) { 5222 !isolate->MayNamedAccess(js_object, name, v8::ACCESS_SET)) {
5223 return isolate->heap()->undefined_value(); 5223 return isolate->heap()->undefined_value();
5224 } 5224 }
5225 5225
5226 LookupResult lookup(isolate); 5226 LookupResult lookup(isolate);
5227 js_object->LocalLookupRealNamedProperty(*name, &lookup); 5227 js_object->LocalLookupRealNamedProperty(*name, &lookup);
5228 5228
5229 // Special case for callback properties. 5229 // Special case for callback properties.
5230 if (lookup.IsPropertyCallbacks()) { 5230 if (lookup.IsPropertyCallbacks()) {
5231 Handle<Object> callback(lookup.GetCallbackObject(), isolate); 5231 Handle<Object> callback(lookup.GetCallbackObject(), isolate);
5232 // To be compatible with Safari we do not change the value on API objects 5232 // Avoid redefining callback as data property, just use the stored
5233 // in Object.defineProperty(). Firefox disagrees here, and actually changes
5234 // the value.
5235 if (callback->IsAccessorInfo()) {
5236 return isolate->heap()->undefined_value();
5237 }
5238 // Avoid redefining foreign callback as data property, just use the stored
5239 // setter to update the value instead. 5233 // setter to update the value instead.
5240 // TODO(mstarzinger): So far this only works if property attributes don't 5234 // TODO(mstarzinger): So far this only works if property attributes don't
5241 // change, this should be fixed once we cleanup the underlying code. 5235 // change, this should be fixed once we cleanup the underlying code.
5242 if (callback->IsForeign() && lookup.GetAttributes() == attr) { 5236 if ((callback->IsForeign() || callback->IsAccessorInfo()) &&
5237 lookup.GetAttributes() == attr) {
5243 Handle<Object> result_object; 5238 Handle<Object> result_object;
5244 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5239 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5245 isolate, result_object, 5240 isolate, result_object,
5246 JSObject::SetPropertyWithCallback(js_object, 5241 JSObject::SetPropertyWithCallback(js_object,
5247 callback, 5242 callback,
5248 name, 5243 name,
5249 obj_value, 5244 obj_value,
5250 handle(lookup.holder()), 5245 handle(lookup.holder()),
5251 STRICT)); 5246 STRICT));
5252 return *result_object; 5247 return *result_object;
(...skipping 9871 matching lines...) Expand 10 before | Expand all | Expand 10 after
15124 } 15119 }
15125 return NULL; 15120 return NULL;
15126 } 15121 }
15127 15122
15128 15123
15129 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15124 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15130 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15125 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15131 } 15126 }
15132 15127
15133 } } // namespace v8::internal 15128 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698