[Webkit-unassigned] [Bug 38636] New: Object.defineProperty doesn't respect attributes when applied to the Global Object

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu May 6 02:53:59 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=38636

           Summary: Object.defineProperty doesn't respect attributes when
                    applied to the Global Object
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: kent.hansen at nokia.com


For a "plain" object, this works as expected:

./jsc
> Object.defineProperty(o, "foo", { writable: false, configurable: false, value: 123 });
[object Object]
> o.foo
123
> o.foo = 456; o.foo
123
> delete o.foo
false

When defining a property on the Global Object, however, the result is
different:

./jsc
> Object.defineProperty(this, "foo", { writable: false, configurable: false, value: 123 });
[object global]
> foo
123
> foo = 456; foo
456
> delete foo
true
> foo
Exception: ReferenceError: Can't find variable: foo

The same happens when using the C API, e.g.:

JSStringRef jsFooString = JSStringCreateWithUTF8CString("foo");
JSValueRef js123Value = JSValueMakeNumber(context, 123);
JSObjectSetProperty(context, globalObject, jsFooString, js123Value,
kJSPropertyAttributeReadOnly, 0);
JSStringRef myScript = JSStringCreateWithUTF8CString("foo = 456; foo");
JSValueRef ret = JSEvaluateScript(context, myScript, 0, 0, 0, 0); // ret will
be 456

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list