<!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>[285639] trunk</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/285639">285639</a></dd>
<dt>Author</dt> <dd>shvaikalesh@gmail.com</dd>
<dt>Date</dt> <dd>2021-11-11 10:29:14 -0800 (Thu, 11 Nov 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>JSCallbackData should use lexical global object for errors and lifecycle
https://bugs.webkit.org/show_bug.cgi?id=232387

Reviewed by Geoff Garen.

LayoutTests/imported/w3c:

* web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-expected.txt: Added.
* web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-expected.txt: Added.
* web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html: Added.
* web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html: Added.
* web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html: Added.
* web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-subframe.html: Added.

Source/WebCore:

Currently, JSCallbackData uses incumbent [1] global object pretty much for everything,
which causes a few issues:

  1) TypeErrors are constructed in incorrect realm;
  2) NodeFilter / XPathNSResolver crash if their incumbent window gets disconnected;
  3) other callbacks, originated in detached frame, were not invoked at all.

Since not all handleEvent() callers have ScriptExecutionContext, and to avoid a large
code diff, this patch utilizes callback wrapper's ScriptExecutionContext to fix all
the above-mentioned problems.

To accomodate NodeFilter and XPathNSResolver of detached frames without growing `sizeof`
of all other other callbacks, m_globalObject member is introduced only for them.

AudioWorklet changes are unobservable as worklets can't acquire a cross-realm method.

[1] https://html.spec.whatwg.org/multipage/webappapis.html#incumbent

Tests: fast/dom/Geolocation/callback-to-deleted-context.html
       imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html
       imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html

* Modules/geolocation/PositionErrorCallback.idl:
* Modules/webaudio/AudioWorkletGlobalScope.cpp:
(WebCore::AudioWorkletGlobalScope::registerProcessor):
(WebCore::AudioWorkletGlobalScope::createProcessor):
* Modules/webaudio/AudioWorkletProcessor.cpp:
(WebCore::AudioWorkletProcessor::create):
(WebCore::AudioWorkletProcessor::AudioWorkletProcessor):
(WebCore::AudioWorkletProcessor::process):
(WebCore::AudioWorkletProcessor::setProcessCallback):
* Modules/webaudio/AudioWorkletProcessor.h:
(WebCore::AudioWorkletProcessor::processCallbackWrapper):
* bindings/js/JSAudioWorkletProcessorCustom.cpp:
(WebCore::JSAudioWorkletProcessor::visitAdditionalChildren):
* bindings/js/JSCallbackData.cpp:
(WebCore::JSCallbackData::invokeCallback):
* bindings/js/JSCallbackData.h:
(WebCore::JSCallbackData::JSCallbackData):
(WebCore::JSCallbackData::~JSCallbackData):
(WebCore::JSCallbackDataStrong::JSCallbackDataStrong):
(WebCore::JSCallbackDataStrong::invokeCallback):
(WebCore::JSCallbackDataWeak::JSCallbackDataWeak):
(WebCore::JSCallbackDataWeak::invokeCallback):
(WebCore::JSCallbackData::globalObject): Deleted.
* bindings/js/JSDOMConvertCallbacks.h:
(WebCore::Converter<IDLCallbackFunction<T>>::convert):
(WebCore::Converter<IDLCallbackInterface<T>>::convert):
* bindings/js/JSDOMConvertXPathNSResolver.h:
(WebCore::Converter<IDLInterface<XPathNSResolver>>::convert):
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSC_DEFINE_HOST_FUNCTION):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::jsDOMWindowInstanceFunction_openDatabaseBody):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackHeaderContent):
(GenerateCallbackImplementationContent):
(JSValueToNativeDOMConvertNeedsGlobalObject):
* bindings/scripts/IDLAttributes.json:
* bindings/scripts/test/JS/*: Updated.
* bindings/scripts/test/TestCallbackFunctionSkipCallbackInvokeCheck.idl: Added.
* bindings/scripts/test/TestCallbackInterface.idl:
* dom/NodeFilter.idl:
* workers/WorkerOrWorkletGlobalScope.h:
* worklets/PaintWorkletGlobalScope.cpp:
(WebCore::PaintWorkletGlobalScope::registerPaint):
* xml/CustomXPathNSResolver.idl:

LayoutTests:

* fast/dom/Geolocation/callback-to-deleted-context-expected.txt:
* fast/dom/Geolocation/callback-to-deleted-context.html:
* fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationcallbacktodeletedcontextexpectedtxt">trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationcallbacktodeletedcontexthtml">trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context.html</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationresourcescallbacktodeletedcontextinner1html">trunk/LayoutTests/fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesgeolocationPositionErrorCallbackidl">trunk/Source/WebCore/Modules/geolocation/PositionErrorCallback.idl</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioWorkletGlobalScopecpp">trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioWorkletProcessorcpp">trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioWorkletProcessorh">trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSAudioWorkletProcessorCustomcpp">trunk/Source/WebCore/bindings/js/JSAudioWorkletProcessorCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCallbackDatacpp">trunk/Source/WebCore/bindings/js/JSCallbackData.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCallbackDatah">trunk/Source/WebCore/bindings/js/JSCallbackData.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMConvertCallbacksh">trunk/Source/WebCore/bindings/js/JSDOMConvertCallbacks.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMConvertXPathNSResolverh">trunk/Source/WebCore/bindings/js/JSDOMConvertXPathNSResolver.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMGlobalObjectcpp">trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp">trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLAttributesjson">trunk/Source/WebCore/bindings/scripts/IDLAttributes.json</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctioncpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionh">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionRethrowcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionRethrowh">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithThisObjectcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithThisObjecth">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithTypedefscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithTypedefsh">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackInterfacecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackInterfaceh">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestDerivedDictionarycpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestDerivedDictionary2cpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary2.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestInheritedDictionarycpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestInheritedDictionary2cpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary2.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestStandaloneDictionarycpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestVoidCallbackFunctioncpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestVoidCallbackFunctionh">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestSupplementalDependenciesdep">trunk/Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestCallbackInterfaceidl">trunk/Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl</a></li>
<li><a href="#trunkSourceWebCoredomNodeFilteridl">trunk/Source/WebCore/dom/NodeFilter.idl</a></li>
<li><a href="#trunkSourceWebCoreworkersWorkerOrWorkletGlobalScopeh">trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h</a></li>
<li><a href="#trunkSourceWebCoreworkletsPaintWorkletGlobalScopecpp">trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlCustomXPathNSResolveridl">trunk/Source/WebCore/xml/CustomXPathNSResolver.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmnullbrowsingcontextexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmnullbrowsingcontexthtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalsupportTreeWalkeracceptNodefiltercrossrealmnullbrowsingcontextsubframehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalsupportTreeWalkeracceptNodefiltercrossrealmsubframehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-subframe.html</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionSkipCallbackInvokeCheckcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionSkipCallbackInvokeCheckh">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestCallbackFunctionSkipCallbackInvokeCheckidl">trunk/Source/WebCore/bindings/scripts/test/TestCallbackFunctionSkipCallbackInvokeCheck.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/LayoutTests/ChangeLog 2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-11-11  Alexey Shvayka  <ashvayka@apple.com>
+
+        JSCallbackData should use lexical global object for errors and lifecycle
+        https://bugs.webkit.org/show_bug.cgi?id=232387
+
+        Reviewed by Geoff Garen.
+
+        * fast/dom/Geolocation/callback-to-deleted-context-expected.txt:
+        * fast/dom/Geolocation/callback-to-deleted-context.html:
+        * fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html:
+
</ins><span class="cx"> 2021-11-11  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Drop support for <object usemap> making <object> interactive
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationcallbacktodeletedcontextexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context-expected.txt (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context-expected.txt  2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context-expected.txt     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -1,10 +1,10 @@
</span><span class="cx"> frame "<!--frame1-->" - has 1 onunload handler(s)
</span><del>-Tests that when a Geolocation request is made from a remote frame, and that frame's script context goes away before the Geolocation callback is made, the callback is not made. If the callback is attempted, a crash will occur.
</del><ins>+Tests that when a Geolocation request is made from a remote frame, callbacks are made as usual even if that frame's browsing context is already null.
</ins><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-PASS No callbacks invoked
</del><ins>+PASS Success callback invoked
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationcallbacktodeletedcontexthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context.html (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context.html  2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/LayoutTests/fast/dom/Geolocation/callback-to-deleted-context.html     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> </head>
</span><span class="cx"> <body>
</span><span class="cx"> <script>
</span><del>-description("Tests that when a Geolocation request is made from a remote frame, and that frame's script context goes away before the Geolocation callback is made, the callback is not made. If the callback is attempted, a crash will occur.");
</del><ins>+description("Tests that when a Geolocation request is made from a remote frame, callbacks are made as usual even if that frame's browsing context is already null.");
</ins><span class="cx"> 
</span><span class="cx"> function onFirstIframeLoaded() {
</span><span class="cx">     iframe.src = 'resources/callback-to-deleted-context-inner2.html';
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx"> 
</span><span class="cx"> function onSecondIframeLoaded() {
</span><span class="cx">     window.setTimeout(function() {
</span><del>-        testPassed('No callbacks invoked');
</del><ins>+        testFailed('No callbacks invoked');
</ins><span class="cx">         finishJSTest();
</span><span class="cx">     }, 500);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationresourcescallbacktodeletedcontextinner1html"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html 2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/LayoutTests/fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html    2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx">           // Make request from remote frame, this frame will be gone by the time the Geolocation
</span><span class="cx">           // object attempts to invoke the callback.
</span><span class="cx">           window.parent.navigator.geolocation.getCurrentPosition(function() {
</span><del>-              parent.testFailed('Success callback invoked unexpectedly');
</del><ins>+              parent.testPassed('Success callback invoked');
</ins><span class="cx">               parent.finishJSTest();
</span><span class="cx">           }, function() {
</span><span class="cx">               parent.testFailed('Error callback invoked unexpectedly');
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-11-11  Alexey Shvayka  <ashvayka@apple.com>
+
+        JSCallbackData should use lexical global object for errors and lifecycle
+        https://bugs.webkit.org/show_bug.cgi?id=232387
+
+        Reviewed by Geoff Garen.
+
+        * web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-expected.txt: Added.
+        * web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-expected.txt: Added.
+        * web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html: Added.
+        * web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html: Added.
+        * web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html: Added.
+        * web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-subframe.html: Added.
+
</ins><span class="cx"> 2021-11-11  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Drop support for <object usemap> making <object> interactive
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-expected.txt (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-expected.txt                            (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-expected.txt       2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+
+PASS parent's |this|, parent's method, parent's filter, parent's root
+PASS parent's |this|, parent's method, parent's filter, iframe's root
+PASS parent's |this|, parent's method, iframe's filter, iframe's root
+PASS parent's |this|, iframes's method, iframe's filter, iframe's root
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmnullbrowsingcontextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-expected.txt (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-expected.txt                              (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-expected.txt 2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS TreeWalker: NodeFilter from detached iframe works as expected
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmnullbrowsingcontexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html                              (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html 2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>TreeWalker: NodeFilter from detached iframe works as expected</title>
+<link rel="help" href="https://dom.spec.whatwg.org/#ref-for-call-a-user-objects-operation%E2%91%A0">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<body>
+<script>
+const t = async_test();
+
+const iframe = document.createElement("iframe");
+iframe.src = "support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html";
+iframe.onload = t.step_func_done(() => {
+    const nodeIterator = iframe.contentWindow.createNodeIterator();
+    iframe.remove();
+
+    assert_equals(iframe.contentWindow, null);
+    assert_equals(nodeIterator.nextNode(), document.body);
+    assert_true(nodeIterator.dummyFilterCalled);
+});
+
+document.body.append(iframe);
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalTreeWalkeracceptNodefiltercrossrealmhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html                            (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html       2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+<!DOCTYPE html>
+<title>TreeWalker: cross-realm NodeFilter throws TypeError of current realm</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="help" href="https://webidl.spec.whatwg.org/#call-a-user-objects-operation">
+
+<body id="treeWalkerRoot">
+<div></div>
+
+<script>
+const iframe = document.createElement("iframe");
+iframe.src = "support/TreeWalker-acceptNode-filter-cross-realm-subframe.html";
+iframe.onload = () => {
+    for (const testCase of iframe.contentWindow.testCases) {
+        test(t => {
+            assert_equals(testCase.actual.constructor, testCase.expected);
+        }, testCase.description);
+    }
+};
+document.body.append(iframe);
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalsupportTreeWalkeracceptNodefiltercrossrealmnullbrowsingcontextsubframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html        2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<!DOCTYPE html>
+
+<script>
+function createNodeIterator() {
+    function filter() {
+        nodeIterator.dummyFilterCalled = true;
+        return true;
+    }
+    const nodeIterator = parent.document.createNodeIterator(parent.document.body, NodeFilter.SHOW_ELEMENT, filter);
+    nodeIterator.dummyFilterCalled = false;
+    return nodeIterator;
+}
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomtraversalsupportTreeWalkeracceptNodefiltercrossrealmsubframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-subframe.html (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-subframe.html                           (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/TreeWalker-acceptNode-filter-cross-realm-subframe.html      2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<!DOCTYPE html>
+
+<body id="treeWalkerRoot">
+<div></div>
+
+<script>
+window.testCases = [];
+
+(function() {
+    let walker = parent.document.createTreeWalker(parent.treeWalkerRoot, NodeFilter.SHOW_ELEMENT, new parent.Object);
+    try { walker.firstChild(); } catch (err) { testCases.push({ actual: err, expected: parent.TypeError, description: "parent's |this|, parent's method, parent's filter, parent's root" }); }
+
+    walker = parent.document.createTreeWalker(treeWalkerRoot, NodeFilter.SHOW_ELEMENT, new parent.Object);
+    try { walker.firstChild(); } catch (err) { testCases.push({ actual: err, expected: parent.TypeError, description: "parent's |this|, parent's method, parent's filter, iframe's root" }); }
+
+    walker = parent.document.createTreeWalker(treeWalkerRoot, NodeFilter.SHOW_ELEMENT, {});
+    try { walker.firstChild(); } catch (err) { testCases.push({ actual: err, expected: parent.TypeError, description: "parent's |this|, parent's method, iframe's filter, iframe's root" }); }
+
+    walker = document.createTreeWalker.call(parent.document, treeWalkerRoot, NodeFilter.SHOW_ELEMENT, {});
+    try { walker.firstChild(); } catch (err) { testCases.push({ actual: err, expected: TypeError, description: "parent's |this|, iframes's method, iframe's filter, iframe's root" }); }
+})();
+</script>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/ChangeLog      2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -1,3 +1,78 @@
</span><ins>+2021-11-11  Alexey Shvayka  <ashvayka@apple.com>
+
+        JSCallbackData should use lexical global object for errors and lifecycle
+        https://bugs.webkit.org/show_bug.cgi?id=232387
+
+        Reviewed by Geoff Garen.
+
+        Currently, JSCallbackData uses incumbent [1] global object pretty much for everything,
+        which causes a few issues:
+
+          1) TypeErrors are constructed in incorrect realm;
+          2) NodeFilter / XPathNSResolver crash if their incumbent window gets disconnected;
+          3) other callbacks, originated in detached frame, were not invoked at all.
+
+        Since not all handleEvent() callers have ScriptExecutionContext, and to avoid a large
+        code diff, this patch utilizes callback wrapper's ScriptExecutionContext to fix all
+        the above-mentioned problems.
+
+        To accomodate NodeFilter and XPathNSResolver of detached frames without growing `sizeof`
+        of all other other callbacks, m_globalObject member is introduced only for them.
+
+        AudioWorklet changes are unobservable as worklets can't acquire a cross-realm method.
+
+        [1] https://html.spec.whatwg.org/multipage/webappapis.html#incumbent
+
+        Tests: fast/dom/Geolocation/callback-to-deleted-context.html
+               imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context.html
+               imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-cross-realm.html
+
+        * Modules/geolocation/PositionErrorCallback.idl:
+        * Modules/webaudio/AudioWorkletGlobalScope.cpp:
+        (WebCore::AudioWorkletGlobalScope::registerProcessor):
+        (WebCore::AudioWorkletGlobalScope::createProcessor):
+        * Modules/webaudio/AudioWorkletProcessor.cpp:
+        (WebCore::AudioWorkletProcessor::create):
+        (WebCore::AudioWorkletProcessor::AudioWorkletProcessor):
+        (WebCore::AudioWorkletProcessor::process):
+        (WebCore::AudioWorkletProcessor::setProcessCallback):
+        * Modules/webaudio/AudioWorkletProcessor.h:
+        (WebCore::AudioWorkletProcessor::processCallbackWrapper):
+        * bindings/js/JSAudioWorkletProcessorCustom.cpp:
+        (WebCore::JSAudioWorkletProcessor::visitAdditionalChildren):
+        * bindings/js/JSCallbackData.cpp:
+        (WebCore::JSCallbackData::invokeCallback):
+        * bindings/js/JSCallbackData.h:
+        (WebCore::JSCallbackData::JSCallbackData):
+        (WebCore::JSCallbackData::~JSCallbackData):
+        (WebCore::JSCallbackDataStrong::JSCallbackDataStrong):
+        (WebCore::JSCallbackDataStrong::invokeCallback):
+        (WebCore::JSCallbackDataWeak::JSCallbackDataWeak):
+        (WebCore::JSCallbackDataWeak::invokeCallback):
+        (WebCore::JSCallbackData::globalObject): Deleted.
+        * bindings/js/JSDOMConvertCallbacks.h:
+        (WebCore::Converter<IDLCallbackFunction<T>>::convert):
+        (WebCore::Converter<IDLCallbackInterface<T>>::convert):
+        * bindings/js/JSDOMConvertXPathNSResolver.h:
+        (WebCore::Converter<IDLInterface<XPathNSResolver>>::convert):
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::JSC_DEFINE_HOST_FUNCTION):
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::jsDOMWindowInstanceFunction_openDatabaseBody):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallbackHeaderContent):
+        (GenerateCallbackImplementationContent):
+        (JSValueToNativeDOMConvertNeedsGlobalObject):
+        * bindings/scripts/IDLAttributes.json:
+        * bindings/scripts/test/JS/*: Updated.
+        * bindings/scripts/test/TestCallbackFunctionSkipCallbackInvokeCheck.idl: Added.
+        * bindings/scripts/test/TestCallbackInterface.idl:
+        * dom/NodeFilter.idl:
+        * workers/WorkerOrWorkletGlobalScope.h:
+        * worklets/PaintWorkletGlobalScope.cpp:
+        (WebCore::PaintWorkletGlobalScope::registerPaint):
+        * xml/CustomXPathNSResolver.idl:
+
</ins><span class="cx"> 2021-11-11  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Drop support for <object usemap> making <object> interactive
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesgeolocationPositionErrorCallbackidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/geolocation/PositionErrorCallback.idl (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/geolocation/PositionErrorCallback.idl       2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/Modules/geolocation/PositionErrorCallback.idl  2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -24,4 +24,5 @@
</span><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     Conditional=GEOLOCATION,
</span><ins>+    SkipCallbackInvokeCheck,
</ins><span class="cx"> ] callback PositionErrorCallback = undefined (GeolocationPositionError error);
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioWorkletGlobalScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp        2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp   2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx">         return Exception { NotSupportedError, "A processor was already registered with this name"_s };
</span><span class="cx"> 
</span><span class="cx">     JSC::JSObject* jsConstructor = processorContructor->callbackData()->callback();
</span><del>-    auto* globalObject = jsConstructor->globalObject();
</del><ins>+    auto* globalObject = scriptExecutionContext()->globalObject();
</ins><span class="cx">     auto& vm = globalObject->vm();
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx"> 
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     JSC::JSObject* jsConstructor = constructor->callbackData()->callback();
</span><del>-    auto* globalObject = constructor->callbackData()->globalObject();
</del><ins>+    auto* globalObject = scriptExecutionContext()->globalObject();
</ins><span class="cx">     JSC::VM& vm = globalObject->vm();
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     JSC::JSLockHolder lock { globalObject };
</span><span class="lines">@@ -154,7 +154,7 @@
</span><span class="cx">     if (!jsProcessor)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    jsProcessor->wrapped().setProcessCallback(makeUnique<JSCallbackDataStrong>(jsProcessor, globalObject));
</del><ins>+    jsProcessor->wrapped().setProcessCallback(jsProcessor);
</ins><span class="cx"> 
</span><span class="cx">     return &jsProcessor->wrapped();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioWorkletProcessorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.cpp  2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.cpp     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -201,13 +201,14 @@
</span><span class="cx">     if (!constructionData)
</span><span class="cx">         return Exception { TypeError, "No pending construction data for this worklet processor"_s };
</span><span class="cx"> 
</span><del>-    return adoptRef(*new AudioWorkletProcessor(*constructionData));
</del><ins>+    return adoptRef(*new AudioWorkletProcessor(context, *constructionData));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> AudioWorkletProcessor::~AudioWorkletProcessor() = default;
</span><span class="cx"> 
</span><del>-AudioWorkletProcessor::AudioWorkletProcessor(const AudioWorkletProcessorConstructionData& constructionData)
-    : m_name(constructionData.name())
</del><ins>+AudioWorkletProcessor::AudioWorkletProcessor(ScriptExecutionContext& context, const AudioWorkletProcessorConstructionData& constructionData)
+    : m_scriptExecutionContext(context)
+    , m_name(constructionData.name())
</ins><span class="cx">     , m_port(constructionData.port())
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!isMainThread());
</span><span class="lines">@@ -236,7 +237,7 @@
</span><span class="cx">     DisableMallocRestrictionsForCurrentThreadScope disableMallocRestrictions;
</span><span class="cx"> 
</span><span class="cx">     ASSERT(m_processCallback);
</span><del>-    auto& globalObject = *m_processCallback->globalObject();
</del><ins>+    auto& globalObject = *jsCast<JSDOMGlobalObject*>(m_scriptExecutionContext.globalObject());
</ins><span class="cx">     ASSERT(globalObject.scriptExecutionContext());
</span><span class="cx">     ASSERT(globalObject.scriptExecutionContext()->isContextThread());
</span><span class="cx"> 
</span><span class="lines">@@ -247,7 +248,7 @@
</span><span class="cx">     buildJSArguments(vm, globalObject, args, inputs, outputs, paramValuesMap);
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    auto result = m_processCallback->invokeCallback(jsUndefined(), args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "process"), returnedException);
</del><ins>+    auto result = JSCallbackData::invokeCallback(globalObject, nullptr, asObject(m_processCallback), jsUndefined(), args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "process"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&globalObject, returnedException);
</span><span class="cx">         threwException = true;
</span><span class="lines">@@ -259,9 +260,9 @@
</span><span class="cx">     return result.toBoolean(&globalObject);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void AudioWorkletProcessor::setProcessCallback(std::unique_ptr<JSCallbackDataStrong>&& processCallback)
</del><ins>+void AudioWorkletProcessor::setProcessCallback(JSObject* processCallback)
</ins><span class="cx"> {
</span><del>-    m_processCallback = WTFMove(processCallback);
</del><ins>+    m_processCallback = { processCallback };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioWorkletProcessorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.h    2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletProcessor.h       2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -59,19 +59,21 @@
</span><span class="cx"> 
</span><span class="cx">     bool process(const Vector<RefPtr<AudioBus>>& inputs, Vector<Ref<AudioBus>>& outputs, const HashMap<String, std::unique_ptr<AudioFloatArray>>& paramValuesMap, bool& threwException);
</span><span class="cx"> 
</span><del>-    void setProcessCallback(std::unique_ptr<JSCallbackDataStrong>&&);
</del><ins>+    void setProcessCallback(JSC::JSObject*);
</ins><span class="cx"> 
</span><ins>+    JSValueInWrappedObject& processCallbackWrapper() { return m_processCallback; }
</ins><span class="cx">     JSValueInWrappedObject& jsInputsWrapper() { return m_jsInputs; }
</span><span class="cx">     JSValueInWrappedObject& jsOutputsWrapper() { return m_jsOutputs; }
</span><span class="cx">     JSValueInWrappedObject& jsParamValuesWrapper() { return m_jsParamValues; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    explicit AudioWorkletProcessor(const AudioWorkletProcessorConstructionData&);
</del><ins>+    explicit AudioWorkletProcessor(ScriptExecutionContext&, const AudioWorkletProcessorConstructionData&);
</ins><span class="cx">     void buildJSArguments(JSC::VM&, JSC::JSGlobalObject&, JSC::MarkedArgumentBufferBase&, const Vector<RefPtr<AudioBus>>& inputs, Vector<Ref<AudioBus>>& outputs, const HashMap<String, std::unique_ptr<AudioFloatArray>>& paramValuesMap);
</span><span class="cx"> 
</span><ins>+    ScriptExecutionContext& m_scriptExecutionContext;
</ins><span class="cx">     String m_name;
</span><span class="cx">     Ref<MessagePort> m_port;
</span><del>-    std::unique_ptr<JSCallbackDataStrong> m_processCallback;
</del><ins>+    JSValueInWrappedObject m_processCallback;
</ins><span class="cx">     JSValueInWrappedObject m_jsInputs;
</span><span class="cx">     JSValueInWrappedObject m_jsOutputs;
</span><span class="cx">     JSValueInWrappedObject m_jsParamValues;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSAudioWorkletProcessorCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSAudioWorkletProcessorCustom.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSAudioWorkletProcessorCustom.cpp       2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/js/JSAudioWorkletProcessorCustom.cpp  2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> void JSAudioWorkletProcessor::visitAdditionalChildren(Visitor& visitor)
</span><span class="cx"> {
</span><span class="cx">     auto& processor = wrapped();
</span><ins>+    processor.processCallbackWrapper().visit(visitor);
</ins><span class="cx">     processor.jsInputsWrapper().visit(visitor);
</span><span class="cx">     processor.jsOutputsWrapper().visit(visitor);
</span><span class="cx">     processor.jsParamValuesWrapper().visit(visitor);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCallbackDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCallbackData.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCallbackData.cpp      2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/js/JSCallbackData.cpp 2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><span class="cx"> // https://webidl.spec.whatwg.org/#call-a-user-objects-operation
</span><del>-JSValue JSCallbackData::invokeCallback(JSDOMGlobalObject& globalObject, JSObject* callback, JSValue thisValue, MarkedArgumentBuffer& args, CallbackType method, PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
</del><ins>+JSValue JSCallbackData::invokeCallback(JSDOMGlobalObject& globalObject, JSDOMGlobalObject*, JSObject* callback, JSValue thisValue, MarkedArgumentBuffer& args, CallbackType method, PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(callback);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCallbackDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCallbackData.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCallbackData.h        2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/js/JSCallbackData.h   2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -47,11 +47,10 @@
</span><span class="cx"> public:
</span><span class="cx">     enum class CallbackType { Function, Object, FunctionOrObject };
</span><span class="cx"> 
</span><del>-    JSDOMGlobalObject* globalObject() { return m_globalObject.get(); }
-
</del><ins>+    WEBCORE_EXPORT static JSC::JSValue invokeCallback(JSDOMGlobalObject&, JSDOMGlobalObject* incumbentGlobalObject, JSC::JSObject* callback, JSC::JSValue thisValue, JSC::MarkedArgumentBuffer&, CallbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException);
</ins><span class="cx"> protected:
</span><del>-    explicit JSCallbackData(JSDOMGlobalObject* globalObject)
-        : m_globalObject(globalObject)
</del><ins>+    explicit JSCallbackData(JSDOMGlobalObject* incumbentGlobalObject)
+        : m_incumbentGlobalObject(incumbentGlobalObject)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -61,11 +60,9 @@
</span><span class="cx">         ASSERT(m_thread.ptr() == &Thread::current());
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><del>-    
-    WEBCORE_EXPORT static JSC::JSValue invokeCallback(JSDOMGlobalObject&, JSC::JSObject* callback, JSC::JSValue thisValue, JSC::MarkedArgumentBuffer&, CallbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException);
</del><span class="cx"> 
</span><ins>+    JSC::Weak<JSDOMGlobalObject> m_incumbentGlobalObject;
</ins><span class="cx"> private:
</span><del>-    JSC::Weak<JSDOMGlobalObject> m_globalObject;
</del><span class="cx"> #if ASSERT_ENABLED
</span><span class="cx">     Ref<Thread> m_thread { Thread::current() };
</span><span class="cx"> #endif
</span><span class="lines">@@ -73,21 +70,17 @@
</span><span class="cx"> 
</span><span class="cx"> class JSCallbackDataStrong : public JSCallbackData {
</span><span class="cx"> public:
</span><del>-    JSCallbackDataStrong(JSC::JSObject* callback, JSDOMGlobalObject* globalObject, void* = nullptr)
-        : JSCallbackData(globalObject)
-        , m_callback(globalObject->vm(), callback)
</del><ins>+    JSCallbackDataStrong(JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject, void* = nullptr)
+        : JSCallbackData(incumbentGlobalObject)
+        , m_callback(incumbentGlobalObject->vm(), callback)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     JSC::JSObject* callback() { return m_callback.get(); }
</span><span class="cx"> 
</span><del>-    JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
</del><ins>+    JSC::JSValue invokeCallback(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSValue thisValue, JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
</ins><span class="cx">     {
</span><del>-        auto* globalObject = this->globalObject();
-        if (!globalObject)
-            return { };
-
-        return JSCallbackData::invokeCallback(*globalObject, callback(), thisValue, args, callbackType, functionName, returnedException);
</del><ins>+        return JSCallbackData::invokeCallback(lexicalGlobalObject, m_incumbentGlobalObject.get(), callback(), thisValue, args, callbackType, functionName, returnedException);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -96,8 +89,8 @@
</span><span class="cx"> 
</span><span class="cx"> class JSCallbackDataWeak : public JSCallbackData {
</span><span class="cx"> public:
</span><del>-    JSCallbackDataWeak(JSC::JSObject* callback, JSDOMGlobalObject* globalObject, void* owner)
-        : JSCallbackData(globalObject)
</del><ins>+    JSCallbackDataWeak(JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject, void* owner)
+        : JSCallbackData(incumbentGlobalObject)
</ins><span class="cx">         , m_callback(callback, &m_weakOwner, owner)
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="lines">@@ -104,13 +97,9 @@
</span><span class="cx"> 
</span><span class="cx">     JSC::JSObject* callback() { return m_callback.get(); }
</span><span class="cx"> 
</span><del>-    JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
</del><ins>+    JSC::JSValue invokeCallback(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSValue thisValue, JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
</ins><span class="cx">     {
</span><del>-        auto* globalObject = this->globalObject();
-        if (!globalObject)
-            return { };
-
-        return JSCallbackData::invokeCallback(*globalObject, callback(), thisValue, args, callbackType, functionName, returnedException);
</del><ins>+        return JSCallbackData::invokeCallback(lexicalGlobalObject, m_incumbentGlobalObject.get(), callback(), thisValue, args, callbackType, functionName, returnedException);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     template<typename Visitor> void visitJSFunction(Visitor&);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMConvertCallbacksh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertCallbacks.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMConvertCallbacks.h 2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertCallbacks.h    2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">     static constexpr bool conversionHasSideEffects = false;
</span><span class="cx"> 
</span><span class="cx">     template<typename ExceptionThrower = DefaultExceptionThrower>
</span><del>-    static RefPtr<T> convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower = ExceptionThrower())
</del><ins>+    static RefPtr<T> convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value, ExceptionThrower&& exceptionThrower = ExceptionThrower())
</ins><span class="cx">     {
</span><span class="cx">         JSC::VM& vm = JSC::getVM(&lexicalGlobalObject);
</span><span class="cx">         auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="lines">@@ -45,7 +45,8 @@
</span><span class="cx">             return nullptr;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return T::create(JSC::asObject(value), &callerGlobalObject(globalObject, vm.topCallFrame));
</del><ins>+        auto& jsDOMGlobalObject = *JSC::jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+        return T::create(jsDOMGlobalObject, JSC::asObject(value), &callerGlobalObject(jsDOMGlobalObject, vm.topCallFrame));
</ins><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -69,7 +70,7 @@
</span><span class="cx"> 
</span><span class="cx"> template<typename T> struct Converter<IDLCallbackInterface<T>> : DefaultConverter<IDLCallbackInterface<T>> {
</span><span class="cx">     template<typename ExceptionThrower = DefaultExceptionThrower>
</span><del>-    static RefPtr<T> convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower = ExceptionThrower())
</del><ins>+    static RefPtr<T> convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value, ExceptionThrower&& exceptionThrower = ExceptionThrower())
</ins><span class="cx">     {
</span><span class="cx">         JSC::VM& vm = JSC::getVM(&lexicalGlobalObject);
</span><span class="cx">         auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="lines">@@ -79,7 +80,8 @@
</span><span class="cx">             return nullptr;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return T::create(JSC::asObject(value), &callerGlobalObject(globalObject, vm.topCallFrame));
</del><ins>+        auto& jsDOMGlobalObject = *JSC::jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+        return T::create(jsDOMGlobalObject, JSC::asObject(value), &callerGlobalObject(jsDOMGlobalObject, vm.topCallFrame));
</ins><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMConvertXPathNSResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertXPathNSResolver.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMConvertXPathNSResolver.h   2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertXPathNSResolver.h      2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -48,7 +48,8 @@
</span><span class="cx">         if (object->inherits<JSXPathNSResolver>(vm))
</span><span class="cx">             return &JSC::jsCast<JSXPathNSResolver*>(object)->wrapped();
</span><span class="cx"> 
</span><del>-        return JSCustomXPathNSResolver::create(object, JSC::jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        auto& jsDOMGlobalObject = *JSC::jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+        return JSCustomXPathNSResolver::create(jsDOMGlobalObject, object, &callerGlobalObject(jsDOMGlobalObject, vm.topCallFrame));
</ins><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp   2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp      2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx">         return JSValue::encode(JSValue(JSC::JSValue::JSFalse));
</span><span class="cx"> 
</span><span class="cx">     auto* jsDOMGlobalObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
</span><del>-    Ref<AbortAlgorithm> abortAlgorithm = JSAbortAlgorithm::create(callFrame->uncheckedArgument(1).getObject(), jsDOMGlobalObject);
</del><ins>+    Ref<AbortAlgorithm> abortAlgorithm = JSAbortAlgorithm::create(*jsDOMGlobalObject, callFrame->uncheckedArgument(1).getObject(), jsDOMGlobalObject);
</ins><span class="cx"> 
</span><span class="cx">     bool result = AbortSignal::whenSignalAborted(abortSignal->wrapped(), WTFMove(abortAlgorithm));
</span><span class="cx">     return JSValue::encode(result ? JSValue(JSC::JSValue::JSTrue) : JSValue(JSC::JSValue::JSFalse));
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp   2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp      2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -606,7 +606,7 @@
</span><span class="cx">         return JSValue::encode(constructEmptyObject(lexicalGlobalObject, castedThis->globalObject()->objectPrototype()));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    auto creationCallback = convert<IDLNullable<IDLCallbackFunction<JSDatabaseCallback>>>(*lexicalGlobalObject, callFrame->argument(4), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) {
</del><ins>+    auto creationCallback = convert<IDLNullable<IDLCallbackFunction<JSDatabaseCallback>>>(*lexicalGlobalObject, callFrame->argument(4), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) {
</ins><span class="cx">         throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 4, "creationCallback", "Window", "openDatabase");
</span><span class="cx">     });
</span><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm    2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -6344,13 +6344,11 @@
</span><span class="cx">     push(@$contentRef, "public:\n");
</span><span class="cx"> 
</span><span class="cx">     # The static create() method.
</span><del>-    push(@$contentRef, "    static Ref<$className> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)\n");
</del><ins>+    push(@$contentRef, "    static Ref<$className> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)\n");
</ins><span class="cx">     push(@$contentRef, "    {\n");
</span><del>-    push(@$contentRef, "        return adoptRef(*new ${className}(callback, globalObject));\n");
</del><ins>+    push(@$contentRef, "        return adoptRef(*new ${className}(globalObject, callback, incumbentGlobalObject));\n");
</ins><span class="cx">     push(@$contentRef, "    }\n\n");
</span><span class="cx"> 
</span><del>-    push(@$contentRef, "    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }\n\n");
-
</del><span class="cx">     push(@$contentRef, "    ~$className() final;\n");
</span><span class="cx"> 
</span><span class="cx">     push(@$contentRef, "    ${callbackDataType}* callbackData() { return m_data; }\n");
</span><span class="lines">@@ -6387,7 +6385,7 @@
</span><span class="cx"> 
</span><span class="cx">     push(@$contentRef, "\nprivate:\n");
</span><span class="cx"> 
</span><del>-    push(@$contentRef, "    ${className}(JSC::JSObject*, JSDOMGlobalObject*);\n\n");
</del><ins>+    push(@$contentRef, "    ${className}(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);\n\n");
</ins><span class="cx"> 
</span><span class="cx">     if ($interfaceOrCallback->extendedAttributes->{IsWeakCallback}) {
</span><span class="cx">         push(@$contentRef, "    bool hasCallback() const final { return m_data && m_data->callback(); }\n\n");
</span><span class="lines">@@ -6396,6 +6394,13 @@
</span><span class="cx">     push(@$contentRef, "    void visitJSFunction(JSC::AbstractSlotVisitor&) override;\n\n") if $interfaceOrCallback->extendedAttributes->{IsWeakCallback};
</span><span class="cx">     push(@$contentRef, "    void visitJSFunction(JSC::SlotVisitor&) override;\n\n") if $interfaceOrCallback->extendedAttributes->{IsWeakCallback};
</span><span class="cx"> 
</span><ins>+    if ($interfaceOrCallback->extendedAttributes->{SkipCallbackInvokeCheck}) {
+        push(@$contentRef, "    JSDOMGlobalObject& globalObject() const { return *m_globalObject.get(); }\n\n");
+    } else {
+        push(@$contentRef, "    JSDOMGlobalObject& globalObject() const { return *JSC::jsCast<JSDOMGlobalObject*>(scriptExecutionContext()->globalObject()); }\n\n");
+    }
+
+    push(@$contentRef, "    JSC::Strong<JSDOMGlobalObject> m_globalObject;\n") if $interfaceOrCallback->extendedAttributes->{SkipCallbackInvokeCheck};
</ins><span class="cx">     push(@$contentRef, "    ${callbackDataType}* m_data;\n");
</span><span class="cx">     push(@$contentRef, "};\n\n");
</span><span class="cx"> 
</span><span class="lines">@@ -6416,9 +6421,10 @@
</span><span class="cx">     $includesRef->{"ScriptExecutionContext.h"} = 1;
</span><span class="cx"> 
</span><span class="cx">     # Constructor
</span><del>-    push(@$contentRef, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n");
-    push(@$contentRef, "    : ${name}(globalObject->scriptExecutionContext())\n");
-    push(@$contentRef, "    , m_data(new ${callbackDataType}(callback, globalObject, this))\n");
</del><ins>+    push(@$contentRef, "${className}::${className}(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)\n");
+    push(@$contentRef, "    : ${name}(globalObject.scriptExecutionContext())\n");
+    push(@$contentRef, "    , m_globalObject(globalObject.vm(), &globalObject)\n") if $interfaceOrCallback->extendedAttributes->{SkipCallbackInvokeCheck};
+    push(@$contentRef, "    , m_data(new ${callbackDataType}(callback, incumbentGlobalObject, this))\n");
</ins><span class="cx">     push(@$contentRef, "{\n");
</span><span class="cx">     push(@$contentRef, "}\n\n");
</span><span class="cx"> 
</span><span class="lines">@@ -6523,13 +6529,13 @@
</span><span class="cx"> 
</span><span class="cx">             # FIXME: This is needed for NodeFilter, which works even for disconnected iframes. We should investigate
</span><span class="cx">             # if that behavior is needed for other callbacks.
</span><del>-            if (!$operation->extendedAttributes->{SkipCallbackInvokeCheck}) {
</del><ins>+            if (!$interfaceOrCallback->extendedAttributes->{SkipCallbackInvokeCheck}) {
</ins><span class="cx">                 push(@$contentRef, "    if (!canInvokeCallback())\n");
</span><span class="cx">                 push(@$contentRef, "        return CallbackResultType::UnableToExecute;\n\n");
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             push(@$contentRef, "    Ref<$className> protectedThis(*this);\n\n");
</span><del>-            push(@$contentRef, "    auto& globalObject = *m_data->globalObject();\n");
</del><ins>+            push(@$contentRef, "    auto& globalObject = this->globalObject();\n");
</ins><span class="cx">             push(@$contentRef, "    auto& vm = globalObject.vm();\n\n");
</span><span class="cx">             push(@$contentRef, "    JSLockHolder lock(vm);\n");
</span><span class="cx"> 
</span><span class="lines">@@ -6547,10 +6553,10 @@
</span><span class="cx"> 
</span><span class="cx">             my $callbackInvocation;
</span><span class="cx">             if (ref($interfaceOrCallback) eq "IDLCallbackFunction") {
</span><del>-                $callbackInvocation = "m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException)";
</del><ins>+                $callbackInvocation = "m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException)";
</ins><span class="cx">             } else {
</span><span class="cx">                 my $callbackType = $numOperations > 1 ? "Object" : "FunctionOrObject";
</span><del>-                $callbackInvocation = "m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::${callbackType}, Identifier::fromString(vm, \"${functionName}\"), returnedException)";
</del><ins>+                $callbackInvocation = "m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::${callbackType}, Identifier::fromString(vm, \"${functionName}\"), returnedException)";
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             if ($operation->type->name eq "undefined") {
</span><span class="lines">@@ -7001,8 +7007,6 @@
</span><span class="cx"> {
</span><span class="cx">     my $type = shift;
</span><span class="cx"> 
</span><del>-    return 1 if $codeGenerator->IsCallbackInterface($type);
-    return 1 if $codeGenerator->IsCallbackFunction($type);
</del><span class="cx">     return JSValueToNativeDOMConvertNeedsGlobalObject(@{$type->subtypes}[1]) if $codeGenerator->IsRecordType($type);
</span><span class="cx">     return 1 if $type->name eq "ScheduledAction";
</span><span class="cx">     return 0;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributesjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json 2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json    2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -478,7 +478,7 @@
</span><span class="cx">             "supportsConjunction": true
</span><span class="cx">         },
</span><span class="cx">         "SkipCallbackInvokeCheck": {
</span><del>-            "contextsAllowed": ["operation", "callback-function"]
</del><ins>+            "contextsAllowed": ["interface", "callback-function"]
</ins><span class="cx">         },
</span><span class="cx">         "SkipVTableValidation": {
</span><span class="cx">             "contextsAllowed": ["interface"]
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp 2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp    2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -30,9 +30,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><del>-JSTestCallbackFunction::JSTestCallbackFunction(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackFunction(globalObject->scriptExecutionContext())
-    , m_data(new JSCallbackDataStrong(callback, globalObject, this))
</del><ins>+JSTestCallbackFunction::JSTestCallbackFunction(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    : TestCallbackFunction(globalObject.scriptExecutionContext())
+    , m_data(new JSCallbackDataStrong(callback, incumbentGlobalObject, this))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackFunction> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</del><ins>+    auto jsResult = m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h   2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h      2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -29,13 +29,11 @@
</span><span class="cx"> 
</span><span class="cx"> class JSTestCallbackFunction final : public TestCallbackFunction {
</span><span class="cx"> public:
</span><del>-    static Ref<JSTestCallbackFunction> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
</del><ins>+    static Ref<JSTestCallbackFunction> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new JSTestCallbackFunction(callback, globalObject));
</del><ins>+        return adoptRef(*new JSTestCallbackFunction(globalObject, callback, incumbentGlobalObject));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
-
</del><span class="cx">     ~JSTestCallbackFunction() final;
</span><span class="cx">     JSCallbackDataStrong* callbackData() { return m_data; }
</span><span class="cx"> 
</span><span class="lines">@@ -43,8 +41,10 @@
</span><span class="cx">     CallbackResult<typename IDLDOMString::ImplementationType> handleEvent(typename IDLLong::ParameterType argument) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    JSTestCallbackFunction(JSC::JSObject*, JSDOMGlobalObject*);
</del><ins>+    JSTestCallbackFunction(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);
</ins><span class="cx"> 
</span><ins>+    JSDOMGlobalObject& globalObject() const { return *JSC::jsCast<JSDOMGlobalObject*>(scriptExecutionContext()->globalObject()); }
+
</ins><span class="cx">     JSCallbackDataStrong* m_data;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionRethrowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp  2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -33,9 +33,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><del>-JSTestCallbackFunctionRethrow::JSTestCallbackFunctionRethrow(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackFunctionRethrow(globalObject->scriptExecutionContext())
-    , m_data(new JSCallbackDataStrong(callback, globalObject, this))
</del><ins>+JSTestCallbackFunctionRethrow::JSTestCallbackFunctionRethrow(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    : TestCallbackFunctionRethrow(globalObject.scriptExecutionContext())
+    , m_data(new JSCallbackDataStrong(callback, incumbentGlobalObject, this))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackFunctionRethrow> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</del><ins>+    auto jsResult = m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         auto throwScope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">         throwException(&lexicalGlobalObject, throwScope, returnedException);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionRethrowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.h    2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.h       2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -29,13 +29,11 @@
</span><span class="cx"> 
</span><span class="cx"> class JSTestCallbackFunctionRethrow final : public TestCallbackFunctionRethrow {
</span><span class="cx"> public:
</span><del>-    static Ref<JSTestCallbackFunctionRethrow> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
</del><ins>+    static Ref<JSTestCallbackFunctionRethrow> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new JSTestCallbackFunctionRethrow(callback, globalObject));
</del><ins>+        return adoptRef(*new JSTestCallbackFunctionRethrow(globalObject, callback, incumbentGlobalObject));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
-
</del><span class="cx">     ~JSTestCallbackFunctionRethrow() final;
</span><span class="cx">     JSCallbackDataStrong* callbackData() { return m_data; }
</span><span class="cx"> 
</span><span class="lines">@@ -43,8 +41,10 @@
</span><span class="cx">     CallbackResult<typename IDLDOMString::ImplementationType> handleEvent(typename IDLSequence<IDLLong>::ParameterType argument) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    JSTestCallbackFunctionRethrow(JSC::JSObject*, JSDOMGlobalObject*);
</del><ins>+    JSTestCallbackFunctionRethrow(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);
</ins><span class="cx"> 
</span><ins>+    JSDOMGlobalObject& globalObject() const { return *JSC::jsCast<JSDOMGlobalObject*>(scriptExecutionContext()->globalObject()); }
+
</ins><span class="cx">     JSCallbackDataStrong* m_data;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionSkipCallbackInvokeCheckcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.cpp (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.cpp                          (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.cpp     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSTestCallbackFunctionSkipCallbackInvokeCheck.h"
+
+#include "JSDOMConvertNumbers.h"
+#include "JSDOMConvertStrings.h"
+#include "JSDOMExceptionHandling.h"
+#include "ScriptExecutionContext.h"
+
+
+namespace WebCore {
+using namespace JSC;
+
+JSTestCallbackFunctionSkipCallbackInvokeCheck::JSTestCallbackFunctionSkipCallbackInvokeCheck(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    : TestCallbackFunctionSkipCallbackInvokeCheck(globalObject.scriptExecutionContext())
+    , m_globalObject(globalObject.vm(), &globalObject)
+    , m_data(new JSCallbackDataStrong(callback, incumbentGlobalObject, this))
+{
+}
+
+JSTestCallbackFunctionSkipCallbackInvokeCheck::~JSTestCallbackFunctionSkipCallbackInvokeCheck()
+{
+    ScriptExecutionContext* context = scriptExecutionContext();
+    // When the context is destroyed, all tasks with a reference to a callback
+    // should be deleted. So if the context is 0, we are on the context thread.
+    if (!context || context->isContextThread())
+        delete m_data;
+    else
+        context->postTask(DeleteCallbackDataTask(m_data));
+#ifndef NDEBUG
+    m_data = nullptr;
+#endif
+}
+
+CallbackResult<typename IDLUnsignedShort::ImplementationType> JSTestCallbackFunctionSkipCallbackInvokeCheck::handleEvent(typename IDLDOMString::ParameterType argument)
+{
+    Ref<JSTestCallbackFunctionSkipCallbackInvokeCheck> protectedThis(*this);
+
+    auto& globalObject = this->globalObject();
+    auto& vm = globalObject.vm();
+
+    JSLockHolder lock(vm);
+    auto& lexicalGlobalObject = globalObject;
+    JSValue thisValue = jsUndefined();
+    MarkedArgumentBuffer args;
+    args.append(toJS<IDLDOMString>(lexicalGlobalObject, argument));
+    ASSERT(!args.hasOverflowed());
+
+    NakedPtr<JSC::Exception> returnedException;
+    auto jsResult = m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
+    if (returnedException) {
+        reportException(&lexicalGlobalObject, returnedException);
+        return CallbackResultType::ExceptionThrown;
+     }
+
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto returnValue = convert<IDLUnsignedShort>(lexicalGlobalObject, jsResult);
+    RETURN_IF_EXCEPTION(throwScope, CallbackResultType::ExceptionThrown);
+    return { WTFMove(returnValue) };
+}
+
+JSC::JSValue toJS(TestCallbackFunctionSkipCallbackInvokeCheck& impl)
+{
+    if (!static_cast<JSTestCallbackFunctionSkipCallbackInvokeCheck&>(impl).callbackData())
+        return jsNull();
+
+    return static_cast<JSTestCallbackFunctionSkipCallbackInvokeCheck&>(impl).callbackData()->callback();
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionSkipCallbackInvokeCheckh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.h (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.h                            (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionSkipCallbackInvokeCheck.h       2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "IDLTypes.h"
+#include "JSCallbackData.h"
+#include "TestCallbackFunctionSkipCallbackInvokeCheck.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class JSTestCallbackFunctionSkipCallbackInvokeCheck final : public TestCallbackFunctionSkipCallbackInvokeCheck {
+public:
+    static Ref<JSTestCallbackFunctionSkipCallbackInvokeCheck> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    {
+        return adoptRef(*new JSTestCallbackFunctionSkipCallbackInvokeCheck(globalObject, callback, incumbentGlobalObject));
+    }
+
+    ~JSTestCallbackFunctionSkipCallbackInvokeCheck() final;
+    JSCallbackDataStrong* callbackData() { return m_data; }
+
+    // Functions
+    CallbackResult<typename IDLUnsignedShort::ImplementationType> handleEvent(typename IDLDOMString::ParameterType argument) override;
+
+private:
+    JSTestCallbackFunctionSkipCallbackInvokeCheck(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);
+
+    JSDOMGlobalObject& globalObject() const { return *m_globalObject.get(); }
+
+    JSC::Strong<JSDOMGlobalObject> m_globalObject;
+    JSCallbackDataStrong* m_data;
+};
+
+JSC::JSValue toJS(TestCallbackFunctionSkipCallbackInvokeCheck&);
+inline JSC::JSValue toJS(TestCallbackFunctionSkipCallbackInvokeCheck* impl) { return impl ? toJS(*impl) : JSC::jsNull(); }
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithThisObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp   2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp      2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -34,9 +34,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><del>-JSTestCallbackFunctionWithThisObject::JSTestCallbackFunctionWithThisObject(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackFunctionWithThisObject(globalObject->scriptExecutionContext())
-    , m_data(new JSCallbackDataStrong(callback, globalObject, this))
</del><ins>+JSTestCallbackFunctionWithThisObject::JSTestCallbackFunctionWithThisObject(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    : TestCallbackFunctionWithThisObject(globalObject.scriptExecutionContext())
+    , m_data(new JSCallbackDataStrong(callback, incumbentGlobalObject, this))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackFunctionWithThisObject> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithThisObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h     2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h        2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -29,13 +29,11 @@
</span><span class="cx"> 
</span><span class="cx"> class JSTestCallbackFunctionWithThisObject final : public TestCallbackFunctionWithThisObject {
</span><span class="cx"> public:
</span><del>-    static Ref<JSTestCallbackFunctionWithThisObject> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
</del><ins>+    static Ref<JSTestCallbackFunctionWithThisObject> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new JSTestCallbackFunctionWithThisObject(callback, globalObject));
</del><ins>+        return adoptRef(*new JSTestCallbackFunctionWithThisObject(globalObject, callback, incumbentGlobalObject));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
-
</del><span class="cx">     ~JSTestCallbackFunctionWithThisObject() final;
</span><span class="cx">     JSCallbackDataStrong* callbackData() { return m_data; }
</span><span class="cx"> 
</span><span class="lines">@@ -43,8 +41,10 @@
</span><span class="cx">     CallbackResult<typename IDLUndefined::ImplementationType> handleEvent(typename IDLInterface<TestNode>::ParameterType thisObject, typename IDLSequence<IDLInterface<TestNode>>::ParameterType parameter) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    JSTestCallbackFunctionWithThisObject(JSC::JSObject*, JSDOMGlobalObject*);
</del><ins>+    JSTestCallbackFunctionWithThisObject(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);
</ins><span class="cx"> 
</span><ins>+    JSDOMGlobalObject& globalObject() const { return *JSC::jsCast<JSDOMGlobalObject*>(scriptExecutionContext()->globalObject()); }
+
</ins><span class="cx">     JSCallbackDataStrong* m_data;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithTypedefscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp     2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp        2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -34,9 +34,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><del>-JSTestCallbackFunctionWithTypedefs::JSTestCallbackFunctionWithTypedefs(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackFunctionWithTypedefs(globalObject->scriptExecutionContext())
-    , m_data(new JSCallbackDataStrong(callback, globalObject, this))
</del><ins>+JSTestCallbackFunctionWithTypedefs::JSTestCallbackFunctionWithTypedefs(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    : TestCallbackFunctionWithTypedefs(globalObject.scriptExecutionContext())
+    , m_data(new JSCallbackDataStrong(callback, incumbentGlobalObject, this))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackFunctionWithTypedefs> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackFunctionWithTypedefsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h       2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h  2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -29,13 +29,11 @@
</span><span class="cx"> 
</span><span class="cx"> class JSTestCallbackFunctionWithTypedefs final : public TestCallbackFunctionWithTypedefs {
</span><span class="cx"> public:
</span><del>-    static Ref<JSTestCallbackFunctionWithTypedefs> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
</del><ins>+    static Ref<JSTestCallbackFunctionWithTypedefs> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new JSTestCallbackFunctionWithTypedefs(callback, globalObject));
</del><ins>+        return adoptRef(*new JSTestCallbackFunctionWithTypedefs(globalObject, callback, incumbentGlobalObject));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
-
</del><span class="cx">     ~JSTestCallbackFunctionWithTypedefs() final;
</span><span class="cx">     JSCallbackDataStrong* callbackData() { return m_data; }
</span><span class="cx"> 
</span><span class="lines">@@ -43,8 +41,10 @@
</span><span class="cx">     CallbackResult<typename IDLUndefined::ImplementationType> handleEvent(typename IDLSequence<IDLNullable<IDLLong>>::ParameterType sequenceArg, typename IDLLong::ParameterType longArg) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    JSTestCallbackFunctionWithTypedefs(JSC::JSObject*, JSDOMGlobalObject*);
</del><ins>+    JSTestCallbackFunctionWithTypedefs(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);
</ins><span class="cx"> 
</span><ins>+    JSDOMGlobalObject& globalObject() const { return *JSC::jsCast<JSDOMGlobalObject*>(scriptExecutionContext()->globalObject()); }
+
</ins><span class="cx">     JSCallbackDataStrong* m_data;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackInterfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp        2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp   2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -120,9 +120,9 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSTestCallbackInterface::JSTestCallbackInterface(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackInterface(globalObject->scriptExecutionContext())
-    , m_data(new JSCallbackDataStrong(callback, globalObject, this))
</del><ins>+JSTestCallbackInterface::JSTestCallbackInterface(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    : TestCallbackInterface(globalObject.scriptExecutionContext())
+    , m_data(new JSCallbackDataStrong(callback, incumbentGlobalObject, this))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -183,7 +183,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -193,7 +193,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithNoParam"), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithNoParam"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -220,7 +220,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithArrayParam"), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithArrayParam"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span><span class="lines">@@ -236,7 +236,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -248,7 +248,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithSerializedScriptValueParam"), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithSerializedScriptValueParam"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span><span class="lines">@@ -264,7 +264,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -275,7 +275,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithStringList"), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithStringList"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span><span class="lines">@@ -291,7 +291,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -302,7 +302,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithBoolean"), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithBoolean"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span><span class="lines">@@ -318,7 +318,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -330,7 +330,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackRequiresThisToPass"), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackRequiresThisToPass"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span><span class="lines">@@ -346,7 +346,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -356,7 +356,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithAReturnValue"), returnedException);
</del><ins>+    auto jsResult = m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithAReturnValue"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span><span class="lines">@@ -375,7 +375,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -386,7 +386,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackThatRethrowsExceptions"), returnedException);
</del><ins>+    auto jsResult = m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackThatRethrowsExceptions"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         auto throwScope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">         throwException(&lexicalGlobalObject, throwScope, returnedException);
</span><span class="lines">@@ -399,33 +399,6 @@
</span><span class="cx">     return { WTFMove(returnValue) };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackInterface::callbackThatSkipsInvokeCheck(typename IDLDictionary<TestCallbackInterface::Dictionary>::ParameterType dictionaryParam)
-{
-    Ref<JSTestCallbackInterface> protectedThis(*this);
-
-    auto& globalObject = *m_data->globalObject();
-    auto& vm = globalObject.vm();
-
-    JSLockHolder lock(vm);
-    auto& lexicalGlobalObject = globalObject;
-    JSValue thisValue = jsUndefined();
-    MarkedArgumentBuffer args;
-    args.append(toJS<IDLDictionary<TestCallbackInterface::Dictionary>>(lexicalGlobalObject, globalObject, dictionaryParam));
-    ASSERT(!args.hasOverflowed());
-
-    NakedPtr<JSC::Exception> returnedException;
-    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackThatSkipsInvokeCheck"), returnedException);
-    if (returnedException) {
-        reportException(&lexicalGlobalObject, returnedException);
-        return CallbackResultType::ExceptionThrown;
-     }
-
-    auto throwScope = DECLARE_THROW_SCOPE(vm);
-    auto returnValue = convert<IDLDOMString>(lexicalGlobalObject, jsResult);
-    RETURN_IF_EXCEPTION(throwScope, CallbackResultType::ExceptionThrown);
-    return { WTFMove(returnValue) };
-}
-
</del><span class="cx"> CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackInterface::callbackWithThisObject(typename IDLInterface<TestNode>::ParameterType thisObject, typename IDLInterface<TestObj>::ParameterType testObjParam)
</span><span class="cx"> {
</span><span class="cx">     if (!canInvokeCallback())
</span><span class="lines">@@ -433,7 +406,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestCallbackInterface> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -444,7 +417,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithThisObject"), returnedException);
</del><ins>+    auto jsResult = m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(vm, "callbackWithThisObject"), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCallbackInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h  2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -33,13 +33,11 @@
</span><span class="cx"> 
</span><span class="cx"> class JSTestCallbackInterface final : public TestCallbackInterface {
</span><span class="cx"> public:
</span><del>-    static Ref<JSTestCallbackInterface> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
</del><ins>+    static Ref<JSTestCallbackInterface> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new JSTestCallbackInterface(callback, globalObject));
</del><ins>+        return adoptRef(*new JSTestCallbackInterface(globalObject, callback, incumbentGlobalObject));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
-
</del><span class="cx">     ~JSTestCallbackInterface() final;
</span><span class="cx">     JSCallbackDataStrong* callbackData() { return m_data; }
</span><span class="cx">     static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
</span><span class="lines">@@ -54,12 +52,13 @@
</span><span class="cx">     CallbackResult<typename IDLUndefined::ImplementationType> callbackRequiresThisToPass(typename IDLLong::ParameterType longParam, typename IDLInterface<TestNode>::ParameterType testNodeParam) override;
</span><span class="cx">     CallbackResult<typename IDLDOMString::ImplementationType> callbackWithAReturnValue() override;
</span><span class="cx">     CallbackResult<typename IDLDOMString::ImplementationType> callbackThatRethrowsExceptions(typename IDLEnumeration<TestCallbackInterface::Enum>::ParameterType enumParam) override;
</span><del>-    CallbackResult<typename IDLDOMString::ImplementationType> callbackThatSkipsInvokeCheck(typename IDLDictionary<TestCallbackInterface::Dictionary>::ParameterType dictionaryParam) override;
</del><span class="cx">     CallbackResult<typename IDLDOMString::ImplementationType> callbackWithThisObject(typename IDLInterface<TestNode>::ParameterType thisObject, typename IDLInterface<TestObj>::ParameterType testObjParam) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    JSTestCallbackInterface(JSC::JSObject*, JSDOMGlobalObject*);
</del><ins>+    JSTestCallbackInterface(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);
</ins><span class="cx"> 
</span><ins>+    JSDOMGlobalObject& globalObject() const { return *JSC::jsCast<JSDOMGlobalObject*>(scriptExecutionContext()->globalObject()); }
+
</ins><span class="cx">     JSCallbackDataStrong* m_data;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestDerivedDictionarycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary.cpp        2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary.cpp   2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!callbackMemberValue.isUndefined()) {
</span><del>-        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue partialBooleanMemberValue;
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!partialCallbackMemberValue.isUndefined()) {
</span><del>-        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue partialRequiredLongMemberValue;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestDerivedDictionary2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary2.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary2.cpp       2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDerivedDictionary2.cpp  2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!callbackMemberValue.isUndefined()) {
</span><del>-        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue stringMemberValue;
</span><span class="lines">@@ -153,7 +153,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!callbackMemberValue.isUndefined()) {
</span><del>-        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue partialBooleanMemberValue;
</span><span class="lines">@@ -188,7 +188,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!partialCallbackMemberValue.isUndefined()) {
</span><del>-        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue partialRequiredLongMemberValue;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestInheritedDictionarycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary.cpp      2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary.cpp 2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!callbackMemberValue.isUndefined()) {
</span><del>-        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue partialBooleanMemberValue;
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!partialCallbackMemberValue.isUndefined()) {
</span><del>-        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue partialRequiredLongMemberValue;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestInheritedDictionary2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary2.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary2.cpp     2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInheritedDictionary2.cpp        2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!callbackMemberValue.isUndefined()) {
</span><del>-        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue stringMemberValue;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp      2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -2009,10 +2009,10 @@
</span><span class="cx">     ASSERT(context->isDocument());
</span><span class="cx">     auto& document = downcast<Document>(*context);
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
</span><del>-    auto testCallback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "testCallback", "TestObject", nullptr); });
</del><ins>+    auto testCallback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "testCallback", "TestObject", nullptr); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1);
</span><del>-    auto testCallbackFunction = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 1, "testCallbackFunction", "TestObject", nullptr); });
</del><ins>+    auto testCallbackFunction = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 1, "testCallbackFunction", "TestObject", nullptr); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     auto object = TestObj::create(document, testCallback.releaseNonNull(), testCallbackFunction.releaseNonNull());
</span><span class="cx">     static_assert(TypeOrExceptionOrUnderlyingType<decltype(object)>::isRef);
</span><span class="lines">@@ -3443,7 +3443,7 @@
</span><span class="cx">     auto& vm = JSC::getVM(&lexicalGlobalObject);
</span><span class="cx">     auto throwScope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     auto& impl = thisObject.wrapped();
</span><del>-    auto nativeValue = convert<IDLRecord<IDLDOMString, IDLCallbackFunction<JSVoidCallback>>>(lexicalGlobalObject, value, *thisObject.globalObject());
</del><ins>+    auto nativeValue = convert<IDLRecord<IDLDOMString, IDLCallbackFunction<JSVoidCallback>>>(lexicalGlobalObject, value);
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, false);
</span><span class="cx">     invokeFunctorPropagatingExceptionIfNecessary(lexicalGlobalObject, throwScope, [&] {
</span><span class="cx">         return impl.setStringVoidCallbackRecordAttr(WTFMove(nativeValue));
</span><span class="lines">@@ -6959,7 +6959,7 @@
</span><span class="cx">     if (UNLIKELY(callFrame->argumentCount() < 1))
</span><span class="cx">         return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
</span><del>-    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackInterfaceArg"); });
</del><ins>+    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackInterfaceArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithCallbackInterfaceArg(callback.releaseNonNull()); })));
</span><span class="cx"> }
</span><span class="lines">@@ -6979,7 +6979,7 @@
</span><span class="cx">     if (UNLIKELY(callFrame->argumentCount() < 1))
</span><span class="cx">         return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
</span><del>-    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithNullableCallbackInterfaceArg"); });
</del><ins>+    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithNullableCallbackInterfaceArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithNullableCallbackInterfaceArg(WTFMove(callback)); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7002,7 +7002,7 @@
</span><span class="cx">     auto nonCallback = convert<IDLLong>(*lexicalGlobalObject, argument0.value());
</span><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1);
</span><del>-    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg"); });
</del><ins>+    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg(WTFMove(nonCallback), callback.releaseNonNull()); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7020,7 +7020,7 @@
</span><span class="cx">     UNUSED_PARAM(callFrame);
</span><span class="cx">     auto& impl = castedThis->wrapped();
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->argument(0);
</span><del>-    auto callback = argument0.value().isUndefined() ? Converter<IDLCallbackInterface<JSTestCallbackInterface>>::ReturnType() : convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalCallbackInterfaceArg"); });
</del><ins>+    auto callback = argument0.value().isUndefined() ? Converter<IDLCallbackInterface<JSTestCallbackInterface>>::ReturnType() : convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalCallbackInterfaceArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithOptionalCallbackInterfaceArg(WTFMove(callback)); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7038,7 +7038,7 @@
</span><span class="cx">     UNUSED_PARAM(callFrame);
</span><span class="cx">     auto& impl = castedThis->wrapped();
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->argument(0);
</span><del>-    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalNullableCallbackInterfaceArg"); });
</del><ins>+    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalNullableCallbackInterfaceArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithOptionalNullableCallbackInterfaceArg(WTFMove(callback)); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7058,7 +7058,7 @@
</span><span class="cx">     if (UNLIKELY(callFrame->argumentCount() < 1))
</span><span class="cx">         return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
</span><del>-    auto callback = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackFunctionArg"); });
</del><ins>+    auto callback = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackFunctionArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithCallbackFunctionArg(callback.releaseNonNull()); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7078,7 +7078,7 @@
</span><span class="cx">     if (UNLIKELY(callFrame->argumentCount() < 1))
</span><span class="cx">         return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
</span><del>-    auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithNullableCallbackFunctionArg"); });
</del><ins>+    auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithNullableCallbackFunctionArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithNullableCallbackFunctionArg(WTFMove(callback)); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7101,7 +7101,7 @@
</span><span class="cx">     auto nonCallback = convert<IDLLong>(*lexicalGlobalObject, argument0.value());
</span><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1);
</span><del>-    auto callback = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackFunctionArg"); });
</del><ins>+    auto callback = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackFunctionArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithNonCallbackArgAndCallbackFunctionArg(WTFMove(nonCallback), callback.releaseNonNull()); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7119,7 +7119,7 @@
</span><span class="cx">     UNUSED_PARAM(callFrame);
</span><span class="cx">     auto& impl = castedThis->wrapped();
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->argument(0);
</span><del>-    auto callback = argument0.value().isUndefined() ? Converter<IDLCallbackFunction<JSTestCallbackFunction>>::ReturnType() : convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalCallbackFunctionArg"); });
</del><ins>+    auto callback = argument0.value().isUndefined() ? Converter<IDLCallbackFunction<JSTestCallbackFunction>>::ReturnType() : convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalCallbackFunctionArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithOptionalCallbackFunctionArg(WTFMove(callback)); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7137,7 +7137,7 @@
</span><span class="cx">     UNUSED_PARAM(callFrame);
</span><span class="cx">     auto& impl = castedThis->wrapped();
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->argument(0);
</span><del>-    auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalNullableCallbackFunctionArg"); });
</del><ins>+    auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalNullableCallbackFunctionArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.methodWithOptionalNullableCallbackFunctionArg(WTFMove(callback)); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7154,7 +7154,7 @@
</span><span class="cx">     UNUSED_PARAM(throwScope);
</span><span class="cx">     UNUSED_PARAM(callFrame);
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->argument(0);
</span><del>-    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackAndOptionalArg"); });
</del><ins>+    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackAndOptionalArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return TestObj::staticMethodWithCallbackAndOptionalArg(WTFMove(callback)); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7173,7 +7173,7 @@
</span><span class="cx">     if (UNLIKELY(callFrame->argumentCount() < 1))
</span><span class="cx">         return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
</span><del>-    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackArg"); });
</del><ins>+    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackArg"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return TestObj::staticMethodWithCallbackArg(callback.releaseNonNull()); })));
</span><span class="cx"> }
</span><span class="lines">@@ -7303,7 +7303,7 @@
</span><span class="cx">     UNUSED_PARAM(callFrame);
</span><span class="cx">     auto& impl = castedThis->wrapped();
</span><span class="cx">     EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
</span><del>-    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "overloadedMethod"); });
</del><ins>+    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "overloadedMethod"); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.overloadedMethod(callback.releaseNonNull()); })));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestStandaloneDictionarycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp     2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp        2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!callbackMemberValue.isUndefined()) {
</span><del>-        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, callbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     JSValue enumMemberValue;
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx">     if (!partialCallbackMemberValue.isUndefined()) {
</span><del>-        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject));
</del><ins>+        result.partialCallbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(lexicalGlobalObject, partialCallbackMemberValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(throwScope, { });
</span><span class="cx">     }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp 2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp    2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -168,10 +168,10 @@
</span><span class="cx">     auto hello = convert<IDLDOMString>(*lexicalGlobalObject, argument0.value());
</span><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1);
</span><del>-    auto testCallbackFunction = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 1, "testCallbackFunction", "TestTypedefs", nullptr); });
</del><ins>+    auto testCallbackFunction = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 1, "testCallbackFunction", "TestTypedefs", nullptr); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2);
</span><del>-    auto testCallbackInterface = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument2.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 2, "testCallbackInterface", "TestTypedefs", nullptr); });
</del><ins>+    auto testCallbackInterface = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument2.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 2, "testCallbackInterface", "TestTypedefs", nullptr); });
</ins><span class="cx">     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx">     auto object = TestTypedefs::create(WTFMove(hello), testCallbackFunction.releaseNonNull(), testCallbackInterface.releaseNonNull());
</span><span class="cx">     static_assert(TypeOrExceptionOrUnderlyingType<decltype(object)>::isRef);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestVoidCallbackFunctioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp     2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp        2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -41,9 +41,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><del>-JSTestVoidCallbackFunction::JSTestVoidCallbackFunction(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestVoidCallbackFunction(globalObject->scriptExecutionContext())
-    , m_data(new JSCallbackDataStrong(callback, globalObject, this))
</del><ins>+JSTestVoidCallbackFunction::JSTestVoidCallbackFunction(JSDOMGlobalObject& globalObject, JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
+    : TestVoidCallbackFunction(globalObject.scriptExecutionContext())
+    , m_data(new JSCallbackDataStrong(callback, incumbentGlobalObject, this))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<JSTestVoidCallbackFunction> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    auto& globalObject = *m_data->globalObject();
</del><ins>+    auto& globalObject = this->globalObject();
</ins><span class="cx">     auto& vm = globalObject.vm();
</span><span class="cx"> 
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx"> 
</span><span class="cx">     NakedPtr<JSC::Exception> returnedException;
</span><del>-    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</del><ins>+    m_data->invokeCallback(lexicalGlobalObject, thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
</ins><span class="cx">     if (returnedException) {
</span><span class="cx">         reportException(&lexicalGlobalObject, returnedException);
</span><span class="cx">         return CallbackResultType::ExceptionThrown;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestVoidCallbackFunctionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.h       2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.h  2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -31,13 +31,11 @@
</span><span class="cx"> 
</span><span class="cx"> class JSTestVoidCallbackFunction final : public TestVoidCallbackFunction {
</span><span class="cx"> public:
</span><del>-    static Ref<JSTestVoidCallbackFunction> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
</del><ins>+    static Ref<JSTestVoidCallbackFunction> create(JSDOMGlobalObject& globalObject, JSC::JSObject* callback, JSDOMGlobalObject* incumbentGlobalObject)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new JSTestVoidCallbackFunction(callback, globalObject));
</del><ins>+        return adoptRef(*new JSTestVoidCallbackFunction(globalObject, callback, incumbentGlobalObject));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
-
</del><span class="cx">     ~JSTestVoidCallbackFunction() final;
</span><span class="cx">     JSCallbackDataStrong* callbackData() { return m_data; }
</span><span class="cx"> 
</span><span class="lines">@@ -45,8 +43,10 @@
</span><span class="cx">     CallbackResult<typename IDLUndefined::ImplementationType> handleEvent(typename IDLFloat32Array::ParameterType arrayParam, typename IDLSerializedScriptValue<SerializedScriptValue>::ParameterType srzParam, typename IDLDOMString::ParameterType strArg, typename IDLBoolean::ParameterType boolParam, typename IDLLong::ParameterType longParam, typename IDLInterface<TestNode>::ParameterType testNodeParam) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    JSTestVoidCallbackFunction(JSC::JSObject*, JSDOMGlobalObject*);
</del><ins>+    JSTestVoidCallbackFunction(JSDOMGlobalObject& lexicalGlobalObject, JSC::JSObject*, JSDOMGlobalObject* incumbentGlobalObject);
</ins><span class="cx"> 
</span><ins>+    JSDOMGlobalObject& globalObject() const { return *JSC::jsCast<JSDOMGlobalObject*>(scriptExecutionContext()->globalObject()); }
+
</ins><span class="cx">     JSCallbackDataStrong* m_data;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestSupplementalDependenciesdep"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep  2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -40,6 +40,9 @@
</span><span class="cx"> JSTestCallbackFunctionRethrow.h: 
</span><span class="cx"> DOMTestCallbackFunctionRethrow.h: 
</span><span class="cx"> WebDOMTestCallbackFunctionRethrow.h: 
</span><ins>+JSTestCallbackFunctionSkipCallbackInvokeCheck.h: 
+DOMTestCallbackFunctionSkipCallbackInvokeCheck.h: 
+WebDOMTestCallbackFunctionSkipCallbackInvokeCheck.h: 
</ins><span class="cx"> JSTestCallbackFunctionWithThisObject.h: 
</span><span class="cx"> DOMTestCallbackFunctionWithThisObject.h: 
</span><span class="cx"> WebDOMTestCallbackFunctionWithThisObject.h: 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestCallbackFunctionSkipCallbackInvokeCheckidl"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/scripts/test/TestCallbackFunctionSkipCallbackInvokeCheck.idl (0 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestCallbackFunctionSkipCallbackInvokeCheck.idl                               (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/TestCallbackFunctionSkipCallbackInvokeCheck.idl  2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    SkipCallbackInvokeCheck
+] callback TestCallbackFunctionSkipCallbackInvokeCheck = unsigned short (DOMString argument);
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestCallbackInterfaceidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl     2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl        2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -52,6 +52,5 @@
</span><span class="cx">     undefined callbackRequiresThisToPass(long longParam, TestNode testNodeParam);
</span><span class="cx">     DOMString callbackWithAReturnValue();
</span><span class="cx">     [RethrowException] DOMString callbackThatRethrowsExceptions(TestCallbackInterfaceEnum enumParam);
</span><del>-    [SkipCallbackInvokeCheck] DOMString callbackThatSkipsInvokeCheck(TestCallbackInterfaceDictionary dictionaryParam);
</del><span class="cx">     [CallbackThisObject=TestNode] DOMString callbackWithThisObject(TestObj testObjParam);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeFilteridl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/NodeFilter.idl (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/NodeFilter.idl  2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/dom/NodeFilter.idl     2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     IsWeakCallback,
</span><ins>+    SkipCallbackInvokeCheck,
</ins><span class="cx">     Exposed=Window
</span><span class="cx"> ] callback interface NodeFilter {
</span><span class="cx">     // Constants for acceptNode().
</span><span class="lines">@@ -42,5 +43,5 @@
</span><span class="cx">     const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400;
</span><span class="cx">     const unsigned long SHOW_NOTATION = 0x00000800; // Historical.
</span><span class="cx"> 
</span><del>-    [SkipCallbackInvokeCheck, RethrowException] unsigned short acceptNode(Node node);
</del><ins>+    [RethrowException] unsigned short acceptNode(Node node);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersWorkerOrWorkletGlobalScopeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h        2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h   2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -78,6 +78,7 @@
</span><span class="cx">     WorkerOrWorkletGlobalScope(WorkerThreadType, Ref<JSC::VM>&&, WorkerOrWorkletThread*);
</span><span class="cx"> 
</span><span class="cx">     // ScriptExecutionContext.
</span><ins>+    ScriptExecutionContext* scriptExecutionContext() const final { return const_cast<WorkerOrWorkletGlobalScope*>(this); }
</ins><span class="cx">     bool isJSExecutionForbidden() const final;
</span><span class="cx"> 
</span><span class="cx">     void markAsClosing() { m_isClosing = true; }
</span><span class="lines">@@ -90,7 +91,6 @@
</span><span class="cx">     void derefScriptExecutionContext() final { deref(); }
</span><span class="cx"> 
</span><span class="cx">     // EventTarget.
</span><del>-    ScriptExecutionContext* scriptExecutionContext() const final { return const_cast<WorkerOrWorkletGlobalScope*>(this); }
</del><span class="cx">     void refEventTarget() final { ref(); }
</span><span class="cx">     void derefEventTarget() final { deref(); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkletsPaintWorkletGlobalScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.cpp (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.cpp        2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.cpp   2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx">         if (paintValue.isUndefined())
</span><span class="cx">             return Exception { TypeError, "The class must have a paint method" };
</span><span class="cx"> 
</span><del>-        RefPtr<JSCSSPaintCallback> paint = convert<IDLCallbackFunction<JSCSSPaintCallback>>(globalObject, paintValue, *jsCast<JSDOMGlobalObject*>(&globalObject));
</del><ins>+        RefPtr<JSCSSPaintCallback> paint = convert<IDLCallbackFunction<JSCSSPaintCallback>>(globalObject, paintValue);
</ins><span class="cx">         RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
</span><span class="cx"> 
</span><span class="cx">         auto paintDefinition = makeUnique<PaintDefinition>(name, paintConstructor.get(), paint.releaseNonNull(), WTFMove(inputProperties), WTFMove(inputArguments));
</span></span></pre></div>
<a id="trunkSourceWebCorexmlCustomXPathNSResolveridl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/CustomXPathNSResolver.idl (285638 => 285639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/CustomXPathNSResolver.idl       2021-11-11 18:27:30 UTC (rev 285638)
+++ trunk/Source/WebCore/xml/CustomXPathNSResolver.idl  2021-11-11 18:29:14 UTC (rev 285639)
</span><span class="lines">@@ -24,6 +24,8 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> // Not using [IsWeakCallback] here as XPathNSResolver wrappers always temporary (no reference is kept)
</span><del>-callback interface CustomXPathNSResolver {
-    [ImplementedAs=lookupNamespaceURIForBindings, SkipCallbackInvokeCheck] DOMString? lookupNamespaceURI(DOMString? prefix);
</del><ins>+[
+    SkipCallbackInvokeCheck,
+] callback interface CustomXPathNSResolver {
+    [ImplementedAs=lookupNamespaceURIForBindings] DOMString? lookupNamespaceURI(DOMString? prefix);
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>