Bug 225997

Summary: [JSC] Call custom accessors / values with their holder's global object
Product: WebKit Reporter: Alexey Shvayka <ashvayka>
Component: JavaScriptCoreAssignee: Alexey Shvayka <ashvayka>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, benjamin, calvaris, cdumez, clopez, darin, esprehn+autocc, ews-watchlist, gyuyoung.kim, joepeck, keith_miller, kondapallykalyan, mark.lam, msaboff, ryuan.choi, saam, sergio, tzagallo, webkit-bug-importer, youennf, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
See Also: https://github.com/web-platform-tests/wpt/pull/29767
Bug Depends on:    
Bug Blocks: 220233, 228943    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
WIP
ews-feeder: commit-queue-
WIP
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing
none
Patch for landing
ashvayka: review+
Patch for landing none

Description Alexey Shvayka 2021-05-19 17:20:24 PDT
[JSC] Call custom accessors / values with their holder's global object
Comment 1 Alexey Shvayka 2021-05-19 17:24:39 PDT
Created attachment 429120 [details]
Patch
Comment 2 Alexey Shvayka 2021-05-23 19:37:10 PDT
Created attachment 429495 [details]
Patch

Fix global object for non-reified properties, use CustomAccessor for JS built-ins, and add tests.
Comment 3 EWS Watchlist 2021-05-23 19:38:26 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 4 Radar WebKit Bug Importer 2021-05-26 17:21:21 PDT
<rdar://problem/78541835>
Comment 5 Alexey Shvayka 2021-06-08 15:02:27 PDT
Created attachment 430897 [details]
Patch

Rebase on top of relanded put() revamp.
Comment 6 Yusuke Suzuki 2021-06-08 19:16:37 PDT
That's really awesome.
Comment 7 Alexey Shvayka 2021-06-22 14:31:06 PDT
Created attachment 431994 [details]
WIP

Introduce CallFrame::callerLexicalGlobalObject() and [CustomNativeFunctionAccessor] extended attribute to accomodate JSLocation setters, which need lexical global object to set document.referrer.
Comment 8 Alexey Shvayka 2021-06-22 14:41:58 PDT
Created attachment 431995 [details]
WIP

Add missing Source/WebCore/bindings/js/JSLocationCustom.h file.
Comment 9 Alexey Shvayka 2021-06-28 23:25:13 PDT
Created attachment 432455 [details]
Patch

Call CustomValue setters with correct realm as well, rework callerGlobalObject() to use vm.topCallFrame for custom accessors, revert changes to create_hash_table, and add tests.
Comment 10 Alexey Shvayka 2021-07-01 11:21:08 PDT
Created attachment 432710 [details]
Patch

Fix --debug build, smsimplify callerGlobalObject(), add test for JSCustomSetterFunction passing correct referrer, and improve ChangeLog.
Comment 11 Alexey Shvayka 2021-07-01 11:26:42 PDT
Created attachment 432711 [details]
Patch

svn add LayoutTests/imported
Comment 12 Alexey Shvayka 2021-07-01 11:29:02 PDT
(In reply to Yusuke Suzuki from comment #6)
> That's really awesome.

Thanks! I would appreciate a review.

Once we land this, implementing RegExpConstructor legacy features (https://bugs.webkit.org/show_bug.cgi?id=220233) would be so much easier.
Comment 13 Darin Adler 2021-07-01 16:51:08 PDT
Looks like a real regression in this test:

    http/tests/security/block-top-level-navigations-by-untrusted-first-party-iframes.html

We should probably hold off on review until that is resolved.
Comment 14 Alexey Shvayka 2021-07-02 07:46:27 PDT
Created attachment 432794 [details]
Patch

Attempt to retrieve VMEntryScope's global object even if vm.topCallFrame is nullptr, fixing the test regression, and make JSCustomSetterFunction test more sophisticated.
Comment 15 Yusuke Suzuki 2021-07-20 03:55:51 PDT
Comment on attachment 432794 [details]
Patch

r=me
Comment 16 Alexey Shvayka 2021-07-22 19:39:04 PDT
Created attachment 434056 [details]
Patch for landing
Comment 17 Alexey Shvayka 2021-07-23 10:58:48 PDT
Created attachment 434099 [details]
Patch for landing

svn add <missing LayoutTest files>.
Comment 18 Alexey Shvayka 2021-07-23 11:09:31 PDT
Comment on attachment 434099 [details]
Patch for landing

I'm putting r+ on my own patch (that was already reviewed by Yusuke (thanks!)) so the GitHub's WPT export bot mark my PR (https://github.com/web-platform-tests/wpt/pull/29767) as reviewed for me to land it.
Comment 19 Alexey Shvayka 2021-07-23 12:23:54 PDT
Created attachment 434110 [details]
Patch for landing

Remove trailing whitespace from wpt/WebIDL/ecmascript-binding/global-object-implicit-this-value-cross-realm.html.
Comment 20 EWS 2021-07-23 13:13:38 PDT
Committed r280256 (239923@main): <https://commits.webkit.org/239923@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 434110 [details].