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);
}
+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");