Commit 48e6274c authored by antonm@chromium.org's avatar antonm@chromium.org

Allows not API functions as inputs for CreationConext method.

Review URL: http://codereview.chromium.org/7552034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8885 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a107387d
......@@ -3163,10 +3163,9 @@ static i::Context* GetCreationContext(i::JSObject* object) {
i::Object* constructor = object->map()->constructor();
i::JSFunction* function;
if (!constructor->IsJSFunction()) {
// API functions have null as a constructor,
// Functions have null as a constructor,
// but any JSFunction knows its context immediately.
ASSERT(object->IsJSFunction() &&
i::JSFunction::cast(object)->shared()->IsApiFunction());
ASSERT(object->IsJSFunction());
function = i::JSFunction::cast(object);
} else {
function = i::JSFunction::cast(constructor);
......
......@@ -14595,6 +14595,24 @@ THREADED_TEST(CreationContext) {
}
THREADED_TEST(CreationContextOfJsFunction) {
HandleScope handle_scope;
Persistent<Context> context = Context::New();
InstallContextId(context, 1);
Local<Object> function;
{
Context::Scope scope(context);
function = CompileRun("function foo() {}; foo").As<Object>();
}
CHECK(function->CreationContext() == context);
CheckContextId(function, 1);
context.Dispose();
}
Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index,
const AccessorInfo& info) {
if (index == 42) return v8_str("yes");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment