Bug 170549

Summary: Cannot Object.seal() or Object.freeze() global "this"
Product: WebKit Reporter: Michael Saboff <msaboff>
Component: JavaScriptCoreAssignee: Michael Saboff <msaboff>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, keith_miller, mark.lam, sbarati
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch mark.lam: review+

Description Michael Saboff 2017-04-06 08:43:39 PDT
The ECMAScript standard describes a isExtensible method for Proxy objects that forwards on to the wrapped object.  See <https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible>. We don’t have that method in JavaScriptCore.

<rdar://problem/31478302>
Comment 1 Saam Barati 2017-04-06 08:48:53 PDT
(In reply to Michael Saboff from comment #0)
> The ECMAScript standard describes a isExtensible method for Proxy objects
> that forwards on to the wrapped object.  See
> <https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-
> internal-slots-isextensible>. We don’t have that method in JavaScriptCore.
> 
> <rdar://problem/31478302>

The spec you linked to is for ProxyObject, not JSProxy. Perhaps the JSProxy info is in the HTML spec?
Comment 2 Michael Saboff 2017-04-06 09:12:16 PDT
(In reply to Saam Barati from comment #1)
> (In reply to Michael Saboff from comment #0)
> > The ECMAScript standard describes a isExtensible method for Proxy objects
> > that forwards on to the wrapped object.  See
> > <https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-
> > internal-slots-isextensible>. We don’t have that method in JavaScriptCore.
> > 
> > <rdar://problem/31478302>
> 
> The spec you linked to is for ProxyObject, not JSProxy. Perhaps the JSProxy
> info is in the HTML spec?

I should have been more specific.  This is needed for the global "this" as it is a JSProxy to the global object.  JSProxy doesn't implement isExtensible, but ProxyObject does.
Comment 3 Michael Saboff 2017-04-06 13:31:02 PDT
Changing the bug title to the symptom of the problem instead the cause.  Doing this since it appears the fix requires changes to other code besides JSProxy.
Comment 4 Michael Saboff 2017-04-06 13:43:01 PDT
Created attachment 306423 [details]
Patch
Comment 5 Michael Saboff 2017-04-06 13:56:49 PDT
Comment on attachment 306423 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=306423&action=review

> Source/JavaScriptCore/interpreter/Interpreter.cpp:1162
> +                    return checkedReturn(throwTypeError(callFrame, throwScope, ASCIILiteral(ReadonlyPropertyWriteError)));

A better error message is NonExtensibleObjectPropertyDefineError.  I made that change locally.
Comment 6 Mark Lam 2017-04-06 13:57:17 PDT
Comment on attachment 306423 [details]
Patch

r=me
Comment 7 Michael Saboff 2017-04-06 17:17:48 PDT
Fix landed in change set r215072: <http://trac.webkit.org/changeset/215072>