<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277814] branches/safari-611-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277814">277814</a></dd>
<dt>Author</dt> <dd>alancoon@apple.com</dd>
<dt>Date</dt> <dd>2021-05-20 12:09:22 -0700 (Thu, 20 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/277613">r277613</a>. rdar://problem/78264256

    REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/271119">r271119</a>): Object methods defined with shorthand notation cannot access "caller" in non-strict mode
    https://bugs.webkit.org/show_bug.cgi?id=225277

    Reviewed by Darin Adler.

    JSTests:

    * stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js: Now covers #157461 and #157863.
    * stress/function-caller-cross-realm-via-call-apply.js: Added, coverage for #34553.
    * stress/function-hidden-as-caller.js: Also adds test case for #102276.

    Source/JavaScriptCore:

    This patch loosens `function.caller` to allow non-strict getters, setters, arrow functions,
    and ES6 methods to be returned as callers, fixing web compatibility.

    The intent of <a href="http://trac.webkit.org/projects/webkit/changeset/230662">r230662</a> is preserved: generator / async functions are never exposed. There is
    no good way to acquire wrapper function from the internal body one, nor from its arguments.
    Also, this behavior is on standards track [1] (seems to be considered desirable).

    [1]: https://github.com/claudepache/es-legacy-function-reflection/blob/master/spec.md#get-functionprototypecaller (step 14)

    * runtime/JSFunction.cpp:
    (JSC::JSC_DEFINE_CUSTOM_GETTER):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277613 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari611branchJSTestsChangeLog">branches/safari-611-branch/JSTests/ChangeLog</a></li>
<li><a href="#branchessafari611branchJSTestsstresscallerandargumentspropertiesforfunctionsthatdonthavethemjs">branches/safari-611-branch/JSTests/stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js</a></li>
<li><a href="#branchessafari611branchJSTestsstressfunctionhiddenascallerjs">branches/safari-611-branch/JSTests/stress/function-hidden-as-caller.js</a></li>
<li><a href="#branchessafari611branchSourceJavaScriptCoreChangeLog">branches/safari-611-branch/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchessafari611branchSourceJavaScriptCoreruntimeJSFunctioncpp">branches/safari-611-branch/Source/JavaScriptCore/runtime/JSFunction.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari611branchJSTestsstressfunctioncallercrossrealmviacallapplyjs">branches/safari-611-branch/JSTests/stress/function-caller-cross-realm-via-call-apply.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari611branchJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-611-branch/JSTests/ChangeLog (277813 => 277814)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-611-branch/JSTests/ChangeLog     2021-05-20 19:09:18 UTC (rev 277813)
+++ branches/safari-611-branch/JSTests/ChangeLog        2021-05-20 19:09:22 UTC (rev 277814)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2021-05-20  Alan Coon  <alancoon@apple.com>
+
+        Cherry-pick r277613. rdar://problem/78264256
+
+    REGRESSION (r271119): Object methods defined with shorthand notation cannot access "caller" in non-strict mode
+    https://bugs.webkit.org/show_bug.cgi?id=225277
+    
+    Reviewed by Darin Adler.
+    
+    JSTests:
+    
+    * stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js: Now covers #157461 and #157863.
+    * stress/function-caller-cross-realm-via-call-apply.js: Added, coverage for #34553.
+    * stress/function-hidden-as-caller.js: Also adds test case for #102276.
+    
+    Source/JavaScriptCore:
+    
+    This patch loosens `function.caller` to allow non-strict getters, setters, arrow functions,
+    and ES6 methods to be returned as callers, fixing web compatibility.
+    
+    The intent of r230662 is preserved: generator / async functions are never exposed. There is
+    no good way to acquire wrapper function from the internal body one, nor from its arguments.
+    Also, this behavior is on standards track [1] (seems to be considered desirable).
+    
+    [1]: https://github.com/claudepache/es-legacy-function-reflection/blob/master/spec.md#get-functionprototypecaller (step 14)
+    
+    * runtime/JSFunction.cpp:
+    (JSC::JSC_DEFINE_CUSTOM_GETTER):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277613 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-17  Alexey Shvayka  <shvaikalesh@gmail.com>
+
+            REGRESSION (r271119): Object methods defined with shorthand notation cannot access "caller" in non-strict mode
+            https://bugs.webkit.org/show_bug.cgi?id=225277
+
+            Reviewed by Darin Adler.
+
+            * stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js: Now covers #157461 and #157863.
+            * stress/function-caller-cross-realm-via-call-apply.js: Added, coverage for #34553.
+            * stress/function-hidden-as-caller.js: Also adds test case for #102276.
+
</ins><span class="cx"> 2021-04-08  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r274699. rdar://problem/76373830
</span></span></pre></div>
<a id="branchessafari611branchJSTestsstresscallerandargumentspropertiesforfunctionsthatdonthavethemjs"></a>
<div class="modfile"><h4>Modified: branches/safari-611-branch/JSTests/stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js (277813 => 277814)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-611-branch/JSTests/stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js   2021-05-20 19:09:18 UTC (rev 277813)
+++ branches/safari-611-branch/JSTests/stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js      2021-05-20 19:09:22 UTC (rev 277814)
</span><span class="lines">@@ -3,15 +3,22 @@
</span><span class="cx">         throw new Error;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const GeneratorFunction = (function* () {}).constructor;
+
</ins><span class="cx"> function test1(f) {
</span><span class="cx">     f.__proto__ = {};
</span><ins>+    assert(!f.hasOwnProperty("caller"));
</ins><span class="cx">     Object.defineProperty(f, "caller", {value:42});
</span><span class="cx">     assert(f.caller === 42);
</span><ins>+    assert(!f.hasOwnProperty("arguments"));
</ins><span class="cx">     Object.defineProperty(f, "arguments", {value:32});
</span><span class="cx">     assert(f.arguments === 32);
</span><span class="cx"> }
</span><span class="cx"> for (let i = 0; i < 1000; ++i) {
</span><ins>+    test1(function () {}.bind());
</ins><span class="cx">     test1(function () { "use strict"; });
</span><ins>+    test1(new Function(`"use strict";`));
+    test1(new GeneratorFunction);
</ins><span class="cx">     test1(class C { });
</span><span class="cx">     test1(() => undefined);
</span><span class="cx">     test1(async function foo(){});
</span><span class="lines">@@ -20,8 +27,10 @@
</span><span class="cx"> 
</span><span class="cx"> function test2(f, p = {}) {
</span><span class="cx">     f.__proto__ = p;
</span><ins>+    assert(!f.hasOwnProperty("caller"));
</ins><span class="cx">     f.caller = 42;
</span><span class="cx">     assert(f.caller === 42);
</span><ins>+    assert(!f.hasOwnProperty("arguments"));
</ins><span class="cx">     f.arguments = 44;
</span><span class="cx">     assert(f.arguments === 44);
</span><span class="cx"> }
</span><span class="lines">@@ -33,7 +42,10 @@
</span><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx">     for (let i = 0; i < 1000; ++i) {
</span><ins>+        test2(function () {}.bind(), proxy);
</ins><span class="cx">         test2(function () { "use strict"; }, proxy);
</span><ins>+        test2(new Function(`"use strict";`), proxy);
+        test2(new GeneratorFunction, proxy);
</ins><span class="cx">         test2(class C { }, proxy);
</span><span class="cx">         test2(() => undefined, proxy);
</span><span class="cx">         test2(async function foo(){}, proxy);
</span><span class="lines">@@ -42,7 +54,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> for (let i = 0; i < 1000; ++i) {
</span><ins>+    test2(function() {}.bind());
</ins><span class="cx">     test2(function () { "use strict"; });
</span><ins>+    test2(new Function(`"use strict";`));
+    test2(new GeneratorFunction);
</ins><span class="cx">     test2(class C { });
</span><span class="cx">     test2(() => undefined);
</span><span class="cx">     test2(async function foo(){});
</span><span class="lines">@@ -51,6 +66,8 @@
</span><span class="cx"> 
</span><span class="cx"> function test3(f) {
</span><span class="cx">     f.__proto__ = {};
</span><ins>+
+    assert(!f.hasOwnProperty("caller"));
</ins><span class="cx">     f.caller = 42;
</span><span class="cx">     assert(f.caller === 42);
</span><span class="cx">     assert(f.hasOwnProperty("caller"));
</span><span class="lines">@@ -58,6 +75,7 @@
</span><span class="cx">     assert(f.caller === undefined);
</span><span class="cx">     assert(!f.hasOwnProperty("caller"));
</span><span class="cx"> 
</span><ins>+    assert(!f.hasOwnProperty("arguments"));
</ins><span class="cx">     f.arguments = 44;
</span><span class="cx">     assert(f.arguments === 44);
</span><span class="cx">     assert(f.hasOwnProperty("arguments"));
</span><span class="lines">@@ -66,9 +84,26 @@
</span><span class="cx">     assert(!f.hasOwnProperty("arguments"));
</span><span class="cx"> }
</span><span class="cx"> for (let i = 0; i < 1000; ++i) {
</span><ins>+    test3(function () {}.bind());
</ins><span class="cx">     test3(function () { "use strict"; });
</span><ins>+    test3(new Function(`"use strict";`));
+    test3(new GeneratorFunction);
</ins><span class="cx">     test3(class C { });
</span><span class="cx">     test3(() => undefined);
</span><span class="cx">     test3(async function foo(){});
</span><span class="cx">     test3(function* foo() { });
</span><span class="cx"> }
</span><ins>+
+for (let i = 0; i < 1000; ++i) {
+    class C1 { static caller() {} }
+    C1.caller = 1;
+    assert(C1.caller === 1);
+
+    class C2 { static arguments() {} }
+    C2.arguments = 2;
+    assert(C2.arguments === 2);
+}
+
+test1(String.prototype.italics);
+test2(Reflect.deleteProperty);
+test3(Math.log1p);
</ins></span></pre></div>
<a id="branchessafari611branchJSTestsstressfunctioncallercrossrealmviacallapplyjs"></a>
<div class="addfile"><h4>Added: branches/safari-611-branch/JSTests/stress/function-caller-cross-realm-via-call-apply.js (0 => 277814)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-611-branch/JSTests/stress/function-caller-cross-realm-via-call-apply.js                          (rev 0)
+++ branches/safari-611-branch/JSTests/stress/function-caller-cross-realm-via-call-apply.js     2021-05-20 19:09:22 UTC (rev 277814)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+function assertCallerName(expectedName) {
+    const { caller } = assertCallerName;
+    if (typeof caller !== "function")
+        throw new Error("caller should be a function!");
+    if (caller.name !== expectedName)
+        throw new Error(`caller.name should be "${expectedName}"! Got "${caller.name}" instead.`);
+}
+
+(function sameRealm() { assertCallerName("sameRealm"); })();  
+(function sameRealmViaCall() { assertCallerName.call(null, "sameRealmViaCall"); })();  
+(function sameRealmViaApply() { assertCallerName.apply(null, ["sameRealmViaApply"]); })();  
+
+const other = $vm.createGlobalObject();
+other.top = globalThis;
+other.eval(`
+    (function crossRealm() { top.assertCallerName("crossRealm"); })();
+    (function crossRealmViaCall() { top.assertCallerName.call(null, "crossRealmViaCall"); })();
+    (function crossRealmViaApply() { top.assertCallerName.apply(null, ["crossRealmViaApply"]); })();
+`);
</ins></span></pre></div>
<a id="branchessafari611branchJSTestsstressfunctionhiddenascallerjs"></a>
<div class="modfile"><h4>Modified: branches/safari-611-branch/JSTests/stress/function-hidden-as-caller.js (277813 => 277814)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-611-branch/JSTests/stress/function-hidden-as-caller.js   2021-05-20 19:09:18 UTC (rev 277813)
+++ branches/safari-611-branch/JSTests/stress/function-hidden-as-caller.js      2021-05-20 19:09:22 UTC (rev 277814)
</span><span class="lines">@@ -3,12 +3,15 @@
</span><span class="cx">         throw new Error(`Bad value: ${actual} (${testInfo})`);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-let caller = null;
</del><ins>+let callerViaGet;
+let callerViaGetOwnProperty;
</ins><span class="cx"> function updateCaller() {
</span><del>-    caller = updateCaller.caller;
</del><ins>+    callerViaGet = updateCaller.caller;
+    callerViaGetOwnProperty = Object.getOwnPropertyDescriptor(updateCaller, "caller").value;
</ins><span class="cx"> }
</span><span class="cx"> noInline(updateCaller);
</span><span class="cx"> 
</span><ins>+function normalSloppyFunction() { updateCaller(); }
</ins><span class="cx"> function normalStrictFunction() { "use strict"; updateCaller(); }
</span><span class="cx"> 
</span><span class="cx"> const { get, set } = Object.getOwnPropertyDescriptor({
</span><span class="lines">@@ -17,24 +20,44 @@
</span><span class="cx"> }, "accessor");
</span><span class="cx"> 
</span><span class="cx"> const arrowFunction = () => { updateCaller(); };
</span><del>-const asyncArrowFunction = async () => { updateCaller(); };
</del><ins>+const asyncArrowFunctionWrapper = async (x = updateCaller()) => {};
+const asyncArrowFunctionBody = async () => { updateCaller() };
</ins><span class="cx"> 
</span><del>-const functionsHiddenAsCallers = [
-    normalStrictFunction,
-    normalStrictFunction.bind(),
</del><ins>+const functionsVisibleAsCallers = [
+    normalSloppyFunction,
</ins><span class="cx">     get,
</span><span class="cx">     set,
</span><span class="cx">     arrowFunction,
</span><del>-    asyncArrowFunction,
-    function* syncGenerator() { updateCaller(); },
-    { * syncGeneratorMethod() { updateCaller(); } }.syncGeneratorMethod,
</del><span class="cx">     { method() { updateCaller(); } }.method,
</span><del>-    async function asyncFunction() { updateCaller(); },
-    { async asyncMethod() { updateCaller(); } }.asyncMethod,
-    async function* asyncGenerator() { updateCaller(); },
-    { async * asyncGeneratorMethod() { updateCaller(); } }.asyncGeneratorMethod,
</del><span class="cx"> ];
</span><span class="cx"> 
</span><ins>+(function visibleAsCallers() {
+    for (const fn of functionsVisibleAsCallers) {
+        for (let i = 0; i < 1e4; ++i) {
+            callerViaGet = undefined;
+            callerViaGetOwnProperty = undefined;
+
+            fn();
+
+            shouldBe(callerViaGet, fn, fn.name);
+            shouldBe(callerViaGetOwnProperty, fn, fn.name);
+        }
+    }
+})();
+
+const functionsHiddenAsCallers = [
+    normalStrictFunction,
+    normalStrictFunction.bind(),
+    asyncArrowFunctionWrapper,
+    asyncArrowFunctionBody,
+    function * syncGeneratorWrapper(x = updateCaller()) {},
+    { * syncGeneratorMethodWrapper(x = updateCaller()) {} }.syncGeneratorMethodWrapper,
+    async function asyncFunctionWrapper(x = updateCaller()) {},
+    { async asyncMethodWrapper(x = updateCaller()) {} }.asyncMethodWrapper,
+    async function * asyncGeneratorWrapper(x = updateCaller()) {},
+    { async * asyncGeneratorMethodWrapper(x = updateCaller()) {} }.asyncGeneratorMethodWrapper,
+];
+
</ins><span class="cx"> const constructorsHiddenAsCallers = [
</span><span class="cx">     class baseConstructor {
</span><span class="cx">         constructor() { updateCaller(); }
</span><span class="lines">@@ -47,17 +70,25 @@
</span><span class="cx"> (function hiddenAsCallers() {
</span><span class="cx">     for (const fn of functionsHiddenAsCallers) {
</span><span class="cx">         for (let i = 0; i < 1e4; ++i) {
</span><del>-            caller = null;
</del><ins>+            callerViaGet = undefined;
+            callerViaGetOwnProperty = undefined;
+
</ins><span class="cx">             fn();
</span><del>-            shouldBe(caller, null, fn.name);
</del><ins>+
+            shouldBe(callerViaGet, null, fn.name);
+            shouldBe(callerViaGetOwnProperty, null, fn.name);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (const C of constructorsHiddenAsCallers) {
</span><span class="cx">         for (let i = 0; i < 1e4; ++i) {
</span><del>-            caller = null;
</del><ins>+            callerViaGet = undefined;
+            callerViaGetOwnProperty = undefined;
+
</ins><span class="cx">             new C();
</span><del>-            shouldBe(caller, null, C.name);
</del><ins>+
+            shouldBe(callerViaGet, null, C.name);
+            shouldBe(callerViaGetOwnProperty, null, C.name);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> })();
</span></span></pre></div>
<a id="branchessafari611branchSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-611-branch/Source/JavaScriptCore/ChangeLog (277813 => 277814)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-611-branch/Source/JavaScriptCore/ChangeLog       2021-05-20 19:09:18 UTC (rev 277813)
+++ branches/safari-611-branch/Source/JavaScriptCore/ChangeLog  2021-05-20 19:09:22 UTC (rev 277814)
</span><span class="lines">@@ -1,5 +1,56 @@
</span><span class="cx"> 2021-05-20  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r277613. rdar://problem/78264256
+
+    REGRESSION (r271119): Object methods defined with shorthand notation cannot access "caller" in non-strict mode
+    https://bugs.webkit.org/show_bug.cgi?id=225277
+    
+    Reviewed by Darin Adler.
+    
+    JSTests:
+    
+    * stress/caller-and-arguments-properties-for-functions-that-dont-have-them.js: Now covers #157461 and #157863.
+    * stress/function-caller-cross-realm-via-call-apply.js: Added, coverage for #34553.
+    * stress/function-hidden-as-caller.js: Also adds test case for #102276.
+    
+    Source/JavaScriptCore:
+    
+    This patch loosens `function.caller` to allow non-strict getters, setters, arrow functions,
+    and ES6 methods to be returned as callers, fixing web compatibility.
+    
+    The intent of r230662 is preserved: generator / async functions are never exposed. There is
+    no good way to acquire wrapper function from the internal body one, nor from its arguments.
+    Also, this behavior is on standards track [1] (seems to be considered desirable).
+    
+    [1]: https://github.com/claudepache/es-legacy-function-reflection/blob/master/spec.md#get-functionprototypecaller (step 14)
+    
+    * runtime/JSFunction.cpp:
+    (JSC::JSC_DEFINE_CUSTOM_GETTER):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277613 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-17  Alexey Shvayka  <shvaikalesh@gmail.com>
+
+            REGRESSION (r271119): Object methods defined with shorthand notation cannot access "caller" in non-strict mode
+            https://bugs.webkit.org/show_bug.cgi?id=225277
+
+            Reviewed by Darin Adler.
+
+            This patch loosens `function.caller` to allow non-strict getters, setters, arrow functions,
+            and ES6 methods to be returned as callers, fixing web compatibility.
+
+            The intent of r230662 is preserved: generator / async functions are never exposed. There is
+            no good way to acquire wrapper function from the internal body one, nor from its arguments.
+            Also, this behavior is on standards track [1] (seems to be considered desirable).
+
+            [1]: https://github.com/claudepache/es-legacy-function-reflection/blob/master/spec.md#get-functionprototypecaller (step 14)
+
+            * runtime/JSFunction.cpp:
+            (JSC::JSC_DEFINE_CUSTOM_GETTER):
+
+2021-05-20  Alan Coon  <alancoon@apple.com>
+
</ins><span class="cx">         Cherry-pick r277477. rdar://problem/78264390
</span><span class="cx"> 
</span><span class="cx">     [REGRESSION: r271876] Web Inspector: [Cocoa] Remote inspection crashes when using WEB_THREAD
</span></span></pre></div>
<a id="branchessafari611branchSourceJavaScriptCoreruntimeJSFunctioncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-611-branch/Source/JavaScriptCore/runtime/JSFunction.cpp (277813 => 277814)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-611-branch/Source/JavaScriptCore/runtime/JSFunction.cpp  2021-05-20 19:09:18 UTC (rev 277813)
+++ branches/safari-611-branch/Source/JavaScriptCore/runtime/JSFunction.cpp     2021-05-20 19:09:22 UTC (rev 277814)
</span><span class="lines">@@ -398,9 +398,17 @@
</span><span class="cx">     if (function->isHostOrBuiltinFunction())
</span><span class="cx">         return JSValue::encode(jsNull());
</span><span class="cx"> 
</span><del>-    if (!function->jsExecutable()->hasCallerAndArgumentsProperties())
</del><ins>+    if (function->jsExecutable()->isInStrictContext())
</ins><span class="cx">         return JSValue::encode(jsNull());
</span><span class="cx"> 
</span><ins>+    // Prevent bodies (private implementations) of generator / async functions from being exposed.
+    // They are called by @generatorResume() & friends, expecting certain arguments, and crash otherwise.
+    // Also, hide generator / async function wrappers for consistency and because it's on standards track:
+    // https://github.com/claudepache/es-legacy-function-reflection/blob/master/spec.md#get-functionprototypecaller (step 14)
+    SourceParseMode parseMode = function->jsExecutable()->parseMode();
+    if (isGeneratorParseMode(parseMode) || isAsyncFunctionParseMode(parseMode))
+        return JSValue::encode(jsNull());
+
</ins><span class="cx">     return JSValue::encode(caller);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>