Bug 133858

Summary: REGRESSION: global object with custom class in iOS 8.0 or OS X 10.10
Product: WebKit Reporter: Isaac Burns <isaacburns>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ggaren, mhahnenberg
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Description Isaac Burns 2014-06-13 08:26:55 PDT
The following code identifies a regression in the iOS SDK 8.0 and OS X SDK 10.10.

JSContextGetGlobalObject no longer returns the object with the custom class.

This may be related to the following bugs.
https://bugs.webkit.org/show_bug.cgi?id=133531
https://bugs.webkit.org/show_bug.cgi?id=133532

#include <JavaScriptCore/JavaScriptCore.h>

static bool _hasProperty(JSContextRef js_ctx, JSObjectRef js_object, JSStringRef js_name)
{
	// iOS SDK 7.1 and OS X SDK 10.9: PASS, iOS SDK 8.0 and OS X SDK 10.10: FAIL
	assert(JSValueIsStrictEqual(js_ctx, js_object, JSContextGetGlobalObject(js_ctx)));
	return false;
}

int main(int argc, char * argv[])
{
	JSClassDefinition js_class_def = kJSClassDefinitionEmpty;
	js_class_def.hasProperty = _hasProperty;
	JSClassRef js_class = JSClassCreate(&js_class_def);
	JSGlobalContextRef js_ctx = JSGlobalContextCreate(js_class);
	// iOS SDK 7.1 and OS X SDK 10.9: PASS, iOS SDK 8.0 and OS X SDK 10.10: FAIL
	assert(JSValueIsObjectOfClass(js_ctx, JSContextGetGlobalObject(js_ctx), js_class));
	JSStringRef js_name = JSStringCreateWithUTF8CString("Object");
	assert(JSObjectHasProperty(js_ctx, JSContextGetGlobalObject(js_ctx), js_name));
	JSStringRelease(js_name); js_name = NULL;
	JSGlobalContextRelease(js_ctx); js_ctx = NULL;
	JSClassRelease(js_class); js_class = NULL;
	return 0;
}
Comment 1 Isaac Burns 2014-06-17 13:38:30 PDT
This continues to be the case with iOS 8.0 Beta 2.
Comment 2 Geoffrey Garen 2014-06-18 11:04:07 PDT
This was an intentional change to make behavior outside of WebKit match behavior inside WebKit.