<!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>[286895] 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/286895">286895</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-12-10 18:26:37 -0800 (Fri, 10 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Some WebIDL operations / attributes incorrectly use _current_ realm instead of _relevant_
https://bugs.webkit.org/show_bug.cgi?id=230941

Patch by Alexey Shvayka <ashvayka@apple.com> on 2021-12-10
Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Import WPT tests from https://github.com/web-platform-tests/wpt/pull/32012.

* web-platform-tests/dom/events/Event-timestamp-cross-realm-getter-expected.txt: Added.
* web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html: Added.
* web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method-expected.txt: Added.
* web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html: Added.
* web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method-expected.txt: Added.
* web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html: Added.
* web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method-expected.txt: Added.
* web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html: Added.
* web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method-expected.txt: Added.
* web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html: Added.
* web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method-expected.txt: Added.
* web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html: Added.
* web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method-expected.txt: Added.
* web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html: Added.

Source/WebCore:

This patch replaces _current_ global object with _relevant_, as per recommendation
for spec authors [1], for select WebIDL operations / attributes that satisfy all
the following conditions:

  1) it's an instance member: static ones and constructors can't use _relevant_;
  2) it's on standards track (not deprecated / WebKit-only / internal);
  3) the change is directly observable: global object is used for something
     beyond lifecycle / event loop / parsing CSS etc;
  4) the change either aligns WebKit with both Blink and Gecko,
     or the spec explicitly requires _relevant_ realm / settings object.

Most of the remaining [CallWith=GlobalObject] instances are correctly used for
converting JS arguments to WebIDL values; the rest, along with _current_ Document
and ScriptExecutionContext, either match the spec or replacing them with _relevant_
global object is not directly observable (see condition #3).

This change is aimed at fixing web-exposed APIs rather than performing a global cleanup.

[1] https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything

Tests: imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html
       imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html
       imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html
       imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html
       imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html
       imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html
       imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html

* Modules/indexeddb/IDBFactory.idl:
https://www.w3.org/TR/IndexedDB/#dom-idbfactory-open (step 2)
https://www.w3.org/TR/IndexedDB/#dom-idbfactory-deletedatabase (step 1)
https://www.w3.org/TR/IndexedDB/#dom-idbfactory-databases (step 1)

* Modules/paymentrequest/PaymentRequest.idl:
https://www.w3.org/TR/payment-request/#show-method (steps 2-4)
https://www.w3.org/TR/payment-request/#can-make-payment-algorithm (before step 1)

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallWith):
* bindings/scripts/IDLAttributes.json:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/TestObj.idl:
* dom/Event.idl:
https://dom.spec.whatwg.org/#inner-event-creation-steps (step 3)

* dom/IdleDeadline.idl:
https://w3c.github.io/requestidlecallback/#the-requestidlecallback-method (step 1)

* page/History.idl:
https://html.spec.whatwg.org/multipage/history.html#dom-history-go (step 1)
https://html.spec.whatwg.org/multipage/history.html#dom-history-back (step 1)
https://html.spec.whatwg.org/multipage/history.html#dom-history-forward (step 1)

* page/DOMWindow.cpp:
(WebCore::DOMWindow::setTimeout):
(WebCore::DOMWindow::setInterval):
* page/DOMWindow.h:
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::setTimeout):
(WebCore::WorkerGlobalScope::setInterval):
* workers/WorkerGlobalScope.h:
Although condition #4 isn't satisfied for setTimeout() / setInterval() because
_current_ global object is used only for logging, replacing it with _relevant_
nicely cleans up method signatures.

* page/WindowOrWorkerGlobalScope.cpp:
(WebCore::WindowOrWorkerGlobalScope::structuredClone):
* page/WindowOrWorkerGlobalScope.h:
* page/WindowOrWorkerGlobalScope.idl:
https://html.spec.whatwg.org/multipage/webappapis.html#report-the-exception
https://html.spec.whatwg.org/multipage/structured-data.html#structured-cloning (step 2)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBFactoryidl">trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl</a></li>
<li><a href="#trunkSourceWebCoreModulespaymentrequestPaymentRequestidl">trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl</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="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestObjidl">trunk/Source/WebCore/bindings/scripts/test/TestObj.idl</a></li>
<li><a href="#trunkSourceWebCoredomEventidl">trunk/Source/WebCore/dom/Event.idl</a></li>
<li><a href="#trunkSourceWebCoredomIdleDeadlineidl">trunk/Source/WebCore/dom/IdleDeadline.idl</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowh">trunk/Source/WebCore/page/DOMWindow.h</a></li>
<li><a href="#trunkSourceWebCorepageHistoryidl">trunk/Source/WebCore/page/History.idl</a></li>
<li><a href="#trunkSourceWebCorepageWindowOrWorkerGlobalScopecpp">trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp</a></li>
<li><a href="#trunkSourceWebCorepageWindowOrWorkerGlobalScopeh">trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.h</a></li>
<li><a href="#trunkSourceWebCorepageWindowOrWorkerGlobalScopeidl">trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.idl</a></li>
<li><a href="#trunkSourceWebCoreworkersWorkerGlobalScopecpp">trunk/Source/WebCore/workers/WorkerGlobalScope.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersWorkerGlobalScopeh">trunk/Source/WebCore/workers/WorkerGlobalScope.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventtimestampcrossrealmgetterexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventtimestampcrossrealmgetterhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_back_cross_realm_methodexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_back_cross_realm_methodhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_forward_cross_realm_methodexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_forward_cross_realm_methodhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_go_cross_realm_methodexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_go_cross_realm_methodhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisscriptingreporterrorcrossrealmmethodexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisscriptingreporterrorcrossrealmmethodhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisstructuredclonestructuredclonecrossrealmmethodexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisstructuredclonestructuredclonecrossrealmmethodhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsrequestidlecallbackcallbacktimeRemainingcrossrealmmethodexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsrequestidlecallbackcallbacktimeRemainingcrossrealmmethodhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -1,5 +1,29 @@
</span><span class="cx"> 2021-12-10  Alexey Shvayka  <ashvayka@apple.com>
</span><span class="cx"> 
</span><ins>+        Some WebIDL operations / attributes incorrectly use _current_ realm instead of _relevant_
+        https://bugs.webkit.org/show_bug.cgi?id=230941
+
+        Reviewed by Sam Weinig.
+
+        Import WPT tests from https://github.com/web-platform-tests/wpt/pull/32012.
+
+        * web-platform-tests/dom/events/Event-timestamp-cross-realm-getter-expected.txt: Added.
+        * web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html: Added.
+        * web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method-expected.txt: Added.
+        * web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html: Added.
+        * web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method-expected.txt: Added.
+        * web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html: Added.
+        * web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method-expected.txt: Added.
+        * web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html: Added.
+        * web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method-expected.txt: Added.
+        * web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html: Added.
+        * web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method-expected.txt: Added.
+        * web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html: Added.
+        * web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method-expected.txt: Added.
+        * web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html: Added.
+
+2021-12-10  Alexey Shvayka  <ashvayka@apple.com>
+
</ins><span class="cx">         Extend the scope where the Window's current event is set
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=233833
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventtimestampcrossrealmgetterexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter-expected.txt (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter-expected.txt                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter-expected.txt        2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS event.timeStamp is initialized using event's relevant global object
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventtimestampcrossrealmgetterhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html        2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+<!doctype html>
+<meta charset="utf-8">
+<title>event.timeStamp is initialized using event's relevant global object</title>
+<link rel="help" href="https://dom.spec.whatwg.org/#ref-for-dom-event-timestamp%E2%91%A1">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<body>
+<script>
+const t = async_test();
+t.step_timeout(() => {
+  const iframeDelayed = document.createElement("iframe");
+  iframeDelayed.onload = t.step_func_done(() => {
+    // Use eval() to eliminate false-positive test result for WebKit builds before r280256,
+    // which invoked WebIDL accessors in context of lexical (caller) global object.
+    const timeStampExpected = iframeDelayed.contentWindow.eval(`new Event("foo").timeStamp`);
+    const eventDelayed = new iframeDelayed.contentWindow.Event("foo");
+
+    const {get} = Object.getOwnPropertyDescriptor(Event.prototype, "timeStamp");
+    assert_approx_equals(get.call(eventDelayed), timeStampExpected, 5, "via Object.getOwnPropertyDescriptor");
+
+    Object.setPrototypeOf(eventDelayed, Event.prototype);
+    assert_approx_equals(eventDelayed.timeStamp, timeStampExpected, 5, "via Object.setPrototypeOf");
+  });
+  document.body.append(iframeDelayed);
+}, 1000);
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_back_cross_realm_methodexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method-expected.txt (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method-expected.txt                               (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method-expected.txt  2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS history.back() uses this's associated document's browsing context to determine if navigation is allowed
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_back_cross_realm_methodhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html                               (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html  2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<!doctype html>
+<meta charset="utf-8">
+<title>history.back() uses this's associated document's browsing context to determine if navigation is allowed</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/history.html#dom-history-back">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id="sandboxedIframe" srcdoc="hello" sandbox="allow-scripts allow-same-origin"></iframe>
+<script>
+const t = async_test();
+
+t.step(() => {
+  history.pushState({}, null, "?prev");
+  history.pushState({}, null, "?current");
+
+  sandboxedIframe.contentWindow.history.back.call(history);
+});
+
+window.onpopstate = t.step_func_done(() => {
+  assert_equals(location.search, "?prev");
+});
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_forward_cross_realm_methodexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method-expected.txt (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method-expected.txt                            (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method-expected.txt       2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS history.forward() uses this's associated document's browsing context to determine if navigation is allowed
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_forward_cross_realm_methodhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html                            (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html       2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+<!doctype html>
+<meta charset="utf-8">
+<title>history.forward() uses this's associated document's browsing context to determine if navigation is allowed</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/history.html#dom-history-forward">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id="sandboxedIframe" srcdoc="hello" sandbox="allow-scripts allow-same-origin"></iframe>
+<script>
+const t = async_test();
+
+t.step(() => {
+  history.pushState({}, null, "?prev");
+  history.pushState({}, null, "?current");
+  history.back();
+});
+
+let isCrossRealmForward = false;
+window.onpopstate = t.step_func(() => {
+  if (isCrossRealmForward) {
+    assert_equals(location.search, "?current");
+    t.done();
+  } else {
+    sandboxedIframe.contentWindow.history.forward.call(history);
+    isCrossRealmForward = true;
+  }
+});
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_go_cross_realm_methodexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method-expected.txt (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method-expected.txt                         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method-expected.txt    2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS history.go() uses this's associated document's browsing context to determine if navigation is allowed
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsershistorythehistoryinterfacehistory_go_cross_realm_methodhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html                         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html    2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+<!doctype html>
+<meta charset="utf-8">
+<title>history.go() uses this's associated document's browsing context to determine if navigation is allowed</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/history.html#dom-history-go">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id="sandboxedIframe" srcdoc="hello" sandbox="allow-scripts allow-same-origin"></iframe>
+<script>
+const t = async_test();
+
+t.step(() => {
+  history.pushState({}, null, "?prev=2");
+  history.pushState({}, null, "?prev=1");
+  history.pushState({}, null, "?current");
+
+  sandboxedIframe.contentWindow.history.go.call(history, -2);
+});
+
+window.onpopstate = t.step_func_done(() => {
+  assert_equals(location.search, "?prev=2");
+});
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisscriptingreporterrorcrossrealmmethodexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method-expected.txt (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method-expected.txt                          (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method-expected.txt     2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+CONSOLE MESSAGE: TypeError: foo
+
+
+PASS self.reportError() dispatches an "error" event for this's relevant global object
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisscriptingreporterrorcrossrealmmethodhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html                          (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html     2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+<!doctype html>
+<meta charset="utf-8">
+<title>self.reportError() dispatches an "error" event for this's relevant global object</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-reporterror">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<body>
+<script>
+setup({ allow_uncaught_exception: true });
+
+async_test(t => {
+  window.addEventListener("error", t.unreached_func("'error' event should not be dispatched for top window!"));
+
+  const iframe = document.createElement("iframe");
+  iframe.onload = t.step_func_done(() => {
+    let eventFired = false;
+    const error = new TypeError("foo");
+    const otherWindow = iframe.contentWindow;
+    otherWindow.addEventListener("error", t.step_func(event => {
+      assert_equals(event.error, error);
+      eventFired = true;
+    }));
+
+    window.reportError.call(otherWindow, error);
+    assert_true(eventFired);
+  });
+  document.body.append(iframe);
+});
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisstructuredclonestructuredclonecrossrealmmethodexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method-expected.txt (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method-expected.txt                              (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method-expected.txt 2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+
+PASS Object instance
+PASS Array instance
+PASS Date instance
+PASS RegExp instance
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlwebappapisstructuredclonestructuredclonecrossrealmmethodhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html                              (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html 2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<!doctype html>
+<title>self.structuredClone() uses this's relevant Realm for deserialization</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/structured-data.html#structured-cloning">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<body>
+<script>
+const iframe = document.createElement("iframe");
+iframe.onload = () => {
+  const otherWindow = iframe.contentWindow;
+  for (const key of ["Object", "Array", "Date", "RegExp"]) {
+    test(() => {
+      const cloned = otherWindow.structuredClone.call(window, new otherWindow[key]);
+      assert_true(cloned instanceof window[key]);
+    }, `${key} instance`);
+  }
+};
+document.body.append(iframe);
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsrequestidlecallbackcallbacktimeRemainingcrossrealmmethodexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method-expected.txt (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method-expected.txt                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method-expected.txt        2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS IdleDeadline::timeRemaining() uses relevant global object as a high-res timestamp origin
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsrequestidlecallbackcallbacktimeRemainingcrossrealmmethodhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html (0 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html        2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!doctype html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
+<meta charset="utf-8">
+<meta name="timeout" content="long">
+<title>IdleDeadline::timeRemaining() uses relevant global object as a high-res timestamp origin</title>
+<link rel="help" href="https://w3c.github.io/requestidlecallback/#dom-idledeadline-timeremaining">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<body>
+<script>
+const t = async_test();
+t.step_timeout(() => {
+  const iframeDelayed = document.createElement("iframe");
+  iframeDelayed.onload = t.step_func(() => {
+    requestIdleCallback(t.step_func_done(deadline => {
+      assert_approx_equals(
+        iframeDelayed.contentWindow.IdleDeadline.prototype.timeRemaining.call(deadline),
+        deadline.timeRemaining(),
+        5,
+      );
+    }));
+  });
+  document.body.append(iframeDelayed);
+}, 1000);
+</script>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/ChangeLog      2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -1,3 +1,82 @@
</span><ins>+2021-12-10  Alexey Shvayka  <ashvayka@apple.com>
+
+        Some WebIDL operations / attributes incorrectly use _current_ realm instead of _relevant_
+        https://bugs.webkit.org/show_bug.cgi?id=230941
+
+        Reviewed by Sam Weinig.
+
+        This patch replaces _current_ global object with _relevant_, as per recommendation
+        for spec authors [1], for select WebIDL operations / attributes that satisfy all
+        the following conditions:
+
+          1) it's an instance member: static ones and constructors can't use _relevant_;
+          2) it's on standards track (not deprecated / WebKit-only / internal);
+          3) the change is directly observable: global object is used for something
+             beyond lifecycle / event loop / parsing CSS etc;
+          4) the change either aligns WebKit with both Blink and Gecko,
+             or the spec explicitly requires _relevant_ realm / settings object.
+
+        Most of the remaining [CallWith=GlobalObject] instances are correctly used for
+        converting JS arguments to WebIDL values; the rest, along with _current_ Document
+        and ScriptExecutionContext, either match the spec or replacing them with _relevant_
+        global object is not directly observable (see condition #3).
+
+        This change is aimed at fixing web-exposed APIs rather than performing a global cleanup.
+
+        [1] https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything
+
+        Tests: imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html
+               imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html
+               imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html
+               imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html
+               imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html
+               imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html
+               imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html
+
+        * Modules/indexeddb/IDBFactory.idl:
+        https://www.w3.org/TR/IndexedDB/#dom-idbfactory-open (step 2)
+        https://www.w3.org/TR/IndexedDB/#dom-idbfactory-deletedatabase (step 1)
+        https://www.w3.org/TR/IndexedDB/#dom-idbfactory-databases (step 1)
+
+        * Modules/paymentrequest/PaymentRequest.idl:
+        https://www.w3.org/TR/payment-request/#show-method (steps 2-4)
+        https://www.w3.org/TR/payment-request/#can-make-payment-algorithm (before step 1)
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallWith):
+        * bindings/scripts/IDLAttributes.json:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/TestObj.idl:
+        * dom/Event.idl:
+        https://dom.spec.whatwg.org/#inner-event-creation-steps (step 3)
+
+        * dom/IdleDeadline.idl:
+        https://w3c.github.io/requestidlecallback/#the-requestidlecallback-method (step 1)
+
+        * page/History.idl:
+        https://html.spec.whatwg.org/multipage/history.html#dom-history-go (step 1)
+        https://html.spec.whatwg.org/multipage/history.html#dom-history-back (step 1)
+        https://html.spec.whatwg.org/multipage/history.html#dom-history-forward (step 1)
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::setTimeout):
+        (WebCore::DOMWindow::setInterval):
+        * page/DOMWindow.h:
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::setTimeout):
+        (WebCore::WorkerGlobalScope::setInterval):
+        * workers/WorkerGlobalScope.h:
+        Although condition #4 isn't satisfied for setTimeout() / setInterval() because
+        _current_ global object is used only for logging, replacing it with _relevant_
+        nicely cleans up method signatures.
+
+        * page/WindowOrWorkerGlobalScope.cpp:
+        (WebCore::WindowOrWorkerGlobalScope::structuredClone):
+        * page/WindowOrWorkerGlobalScope.h:
+        * page/WindowOrWorkerGlobalScope.idl:
+        https://html.spec.whatwg.org/multipage/webappapis.html#report-the-exception
+        https://html.spec.whatwg.org/multipage/structured-data.html#structured-cloning (step 2)
+
</ins><span class="cx"> 2021-12-10  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><span class="cx">         WKWebView doesn’t respond to -copyFont: and -pasteFont:
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBFactoryidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl    2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl       2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -27,10 +27,10 @@
</span><span class="cx">     SkipVTableValidation,
</span><span class="cx">     Exposed=(Window,Worker)
</span><span class="cx"> ] interface IDBFactory {
</span><del>-    [NewObject, CallWith=ScriptExecutionContext] IDBOpenDBRequest open(DOMString name, optional [EnforceRange] unsigned long long version);
-    [NewObject, CallWith=ScriptExecutionContext] IDBOpenDBRequest deleteDatabase(DOMString name);
</del><ins>+    [NewObject, CallWith=RelevantScriptExecutionContext] IDBOpenDBRequest open(DOMString name, optional [EnforceRange] unsigned long long version);
+    [NewObject, CallWith=RelevantScriptExecutionContext] IDBOpenDBRequest deleteDatabase(DOMString name);
</ins><span class="cx">     
</span><del>-    [CallWith=ScriptExecutionContext] Promise<sequence<IDBDatabaseInfo>> databases();
</del><ins>+    [CallWith=RelevantScriptExecutionContext] Promise<sequence<IDBDatabaseInfo>> databases();
</ins><span class="cx">     
</span><span class="cx">     [CallWith=GlobalObject] short cmp(any first, any second);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulespaymentrequestPaymentRequestidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl   2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl      2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -33,9 +33,9 @@
</span><span class="cx"> ] interface PaymentRequest : EventTarget {
</span><span class="cx">     [CallWith=Document] constructor(sequence<PaymentMethodData> methodData, PaymentDetailsInit details, optional PaymentOptions options);
</span><span class="cx"> 
</span><del>-    [CallWith=Document] Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise);
</del><ins>+    [CallWith=RelevantDocument] Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise);
</ins><span class="cx">     Promise<undefined> abort();
</span><del>-    [CallWith=Document] Promise<boolean> canMakePayment();
</del><ins>+    [CallWith=RelevantDocument] Promise<boolean> canMakePayment();
</ins><span class="cx"> 
</span><span class="cx">     readonly attribute DOMString id;
</span><span class="cx">     readonly attribute PaymentAddress? shippingAddress;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm    2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -5936,9 +5936,16 @@
</span><span class="cx">         push(@callWithArgs, "*${globalObject}");
</span><span class="cx">         push(@callWithArgs, $callFrameReference);
</span><span class="cx">     }
</span><ins>+    # Global object of current realm (https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything)
</ins><span class="cx">     if ($codeGenerator->ExtendedAttributeContains($callWith, "GlobalObject")) {
</span><span class="cx">         push(@callWithArgs, "*${globalObject}");
</span><span class="cx">     }
</span><ins>+    my $relevantGlobalObjectPointer = "(${thisReference}).globalObject()";
+    # Global object of relevant realm (https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-everything)
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "RelevantGlobalObject")) {
+        push(@callWithArgs, "*${relevantGlobalObjectPointer}");
+    }
+    # Script execution context of current realm (https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything)
</ins><span class="cx">     if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) {
</span><span class="cx">         push(@$outputArray, $indent . "auto* context = ${scriptExecutionContextAccessor}->scriptExecutionContext();\n");
</span><span class="cx">         push(@$outputArray, $indent . "if (UNLIKELY(!context))\n");
</span><span class="lines">@@ -5945,6 +5952,14 @@
</span><span class="cx">         push(@$outputArray, $indent . "    return" . ($contextMissing ? " " . $contextMissing : "") . ";\n");
</span><span class="cx">         push(@callWithArgs, "*context");
</span><span class="cx">     }
</span><ins>+    # Script execution context of relevant realm (https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-everything)
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "RelevantScriptExecutionContext")) {
+        push(@$outputArray, $indent . "auto* context = ${relevantGlobalObjectPointer}->scriptExecutionContext();\n");
+        push(@$outputArray, $indent . "if (UNLIKELY(!context))\n");
+        push(@$outputArray, $indent . "    return" . ($contextMissing ? " " . $contextMissing : "") . ";\n");
+        push(@callWithArgs, "*context");
+    }
+    # Document of current realm (https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything)
</ins><span class="cx">     if ($codeGenerator->ExtendedAttributeContains($callWith, "Document")) {
</span><span class="cx">         AddToImplIncludes("Document.h");
</span><span class="cx">         push(@$outputArray, $indent . "auto* context = ${scriptExecutionContextAccessor}->scriptExecutionContext();\n");
</span><span class="lines">@@ -5954,6 +5969,16 @@
</span><span class="cx">         push(@$outputArray, $indent . "auto& document = downcast<Document>(*context);\n");
</span><span class="cx">         push(@callWithArgs, "document");
</span><span class="cx">     }
</span><ins>+    # Document of relevant realm (https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-everything)
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "RelevantDocument")) {
+        AddToImplIncludes("Document.h");
+        push(@$outputArray, $indent . "auto* context = ${relevantGlobalObjectPointer}->scriptExecutionContext();\n");
+        push(@$outputArray, $indent . "if (UNLIKELY(!context))\n");
+        push(@$outputArray, $indent . "    return" . ($contextMissing ? " " . $contextMissing : "") . ";\n");
+        push(@$outputArray, $indent . "ASSERT(context->isDocument());\n");
+        push(@$outputArray, $indent . "auto& document = downcast<Document>(*context);\n");
+        push(@callWithArgs, "document");
+    }
</ins><span class="cx">     if ($codeGenerator->ExtendedAttributeContains($callWith, "IncumbentDocument")) {
</span><span class="cx">         AddToImplIncludes("DOMWindow.h");
</span><span class="cx">         AddToImplIncludes("JSDOMWindowBase.h");
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributesjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json 2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json    2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -51,7 +51,11 @@
</span><span class="cx">         },
</span><span class="cx">         "CallWith": {
</span><span class="cx">             "contextsAllowed": ["attribute", "operation"],
</span><del>-            "values": ["Document", "ExecState", "ScriptExecutionContext", "GlobalObject", "ActiveWindow", "FirstWindow", "EntryDocument", "World", "PropertyName"],
</del><ins>+            "values": ["Document", "RelevantDocument", "ExecState", "ScriptExecutionContext", "RelevantScriptExecutionContext", "GlobalObject", "RelevantGlobalObject", "ActiveWindow", "FirstWindow", "EntryDocument", "World", "PropertyName"],
+            "standard": {
+                "url": "https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything",
+                "note": "Currently, Document / ScriptExecutionContext / GlobalObject values denote current realm, which is a [[Realm]] of the currently-running function object."
+            },
</ins><span class="cx">             "supportsConjunction": true
</span><span class="cx">         },
</span><span class="cx">         "CheckSecurity": {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp      2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -1520,11 +1520,14 @@
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_addEventListener);
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_removeEventListener);
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withExecStateVoid);
</span><ins>+static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantGlobalObjectVoid);
</ins><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withExecStateObj);
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withScriptExecutionContext);
</span><ins>+static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantScriptExecutionContext);
</ins><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecState);
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecStateWithSpaces);
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withDocumentArgument);
</span><ins>+static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantDocumentArgument);
</ins><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withCallerDocumentArgument);
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withCallerWindowArgument);
</span><span class="cx"> static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_methodWithOptionalArg);
</span><span class="lines">@@ -2243,11 +2246,14 @@
</span><span class="cx">     { "addEventListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_addEventListener), (intptr_t) (2) } },
</span><span class="cx">     { "removeEventListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_removeEventListener), (intptr_t) (2) } },
</span><span class="cx">     { "withExecStateVoid", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withExecStateVoid), (intptr_t) (0) } },
</span><ins>+    { "withRelevantGlobalObjectVoid", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withRelevantGlobalObjectVoid), (intptr_t) (0) } },
</ins><span class="cx">     { "withExecStateObj", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withExecStateObj), (intptr_t) (0) } },
</span><span class="cx">     { "withScriptExecutionContext", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withScriptExecutionContext), (intptr_t) (0) } },
</span><ins>+    { "withRelevantScriptExecutionContext", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withRelevantScriptExecutionContext), (intptr_t) (0) } },
</ins><span class="cx">     { "withScriptExecutionContextAndExecState", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecState), (intptr_t) (0) } },
</span><span class="cx">     { "withScriptExecutionContextAndExecStateWithSpaces", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecStateWithSpaces), (intptr_t) (0) } },
</span><span class="cx">     { "withDocumentArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withDocumentArgument), (intptr_t) (0) } },
</span><ins>+    { "withRelevantDocumentArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withRelevantDocumentArgument), (intptr_t) (0) } },
</ins><span class="cx">     { "withCallerDocumentArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withCallerDocumentArgument), (intptr_t) (0) } },
</span><span class="cx">     { "withCallerWindowArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withCallerWindowArgument), (intptr_t) (0) } },
</span><span class="cx">     { "methodWithOptionalArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_methodWithOptionalArg), (intptr_t) (0) } },
</span><span class="lines">@@ -6220,6 +6226,21 @@
</span><span class="cx">     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withExecStateVoidBody>(*lexicalGlobalObject, *callFrame, "withExecStateVoid");
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withRelevantGlobalObjectVoidBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
+{
+    auto& vm = JSC::getVM(lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(callFrame);
+    auto& impl = castedThis->wrapped();
+    RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.withRelevantGlobalObjectVoid(*(*castedThis).globalObject()); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantGlobalObjectVoid, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
+{
+    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withRelevantGlobalObjectVoidBody>(*lexicalGlobalObject, *callFrame, "withRelevantGlobalObjectVoid");
+}
+
</ins><span class="cx"> static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withExecStateObjBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
</span><span class="cx"> {
</span><span class="cx">     auto& vm = JSC::getVM(lexicalGlobalObject);
</span><span class="lines">@@ -6253,6 +6274,24 @@
</span><span class="cx">     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withScriptExecutionContextBody>(*lexicalGlobalObject, *callFrame, "withScriptExecutionContext");
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withRelevantScriptExecutionContextBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
+{
+    auto& vm = JSC::getVM(lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(callFrame);
+    auto& impl = castedThis->wrapped();
+    auto* context = (*castedThis).globalObject()->scriptExecutionContext();
+    if (UNLIKELY(!context))
+        return JSValue::encode(jsUndefined());
+    RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.withRelevantScriptExecutionContext(*context); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantScriptExecutionContext, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
+{
+    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withRelevantScriptExecutionContextBody>(*lexicalGlobalObject, *callFrame, "withRelevantScriptExecutionContext");
+}
+
</ins><span class="cx"> static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withScriptExecutionContextAndExecStateBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
</span><span class="cx"> {
</span><span class="cx">     auto& vm = JSC::getVM(lexicalGlobalObject);
</span><span class="lines">@@ -6309,6 +6348,26 @@
</span><span class="cx">     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withDocumentArgumentBody>(*lexicalGlobalObject, *callFrame, "withDocumentArgument");
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withRelevantDocumentArgumentBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
+{
+    auto& vm = JSC::getVM(lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(callFrame);
+    auto& impl = castedThis->wrapped();
+    auto* context = (*castedThis).globalObject()->scriptExecutionContext();
+    if (UNLIKELY(!context))
+        return JSValue::encode(jsUndefined());
+    ASSERT(context->isDocument());
+    auto& document = downcast<Document>(*context);
+    RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.withRelevantDocumentArgument(document); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantDocumentArgument, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
+{
+    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withRelevantDocumentArgumentBody>(*lexicalGlobalObject, *callFrame, "withRelevantDocumentArgument");
+}
+
</ins><span class="cx"> static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withCallerDocumentArgumentBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
</span><span class="cx"> {
</span><span class="cx">     auto& vm = JSC::getVM(lexicalGlobalObject);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl   2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl      2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -190,11 +190,14 @@
</span><span class="cx"> 
</span><span class="cx">     // 'CallWith' extended attribute
</span><span class="cx">     [CallWith=GlobalObject] undefined withExecStateVoid();
</span><ins>+    [CallWith=RelevantGlobalObject] undefined withRelevantGlobalObjectVoid();
</ins><span class="cx">     [CallWith=GlobalObject] TestObj withExecStateObj();
</span><span class="cx">     [CallWith=ScriptExecutionContext] undefined withScriptExecutionContext();
</span><ins>+    [CallWith=RelevantScriptExecutionContext] undefined withRelevantScriptExecutionContext();
</ins><span class="cx">     [CallWith=ScriptExecutionContext&ExecState] undefined withScriptExecutionContextAndExecState();
</span><span class="cx">     [CallWith=  ScriptExecutionContext  &  ExecState  ] TestObj withScriptExecutionContextAndExecStateWithSpaces();
</span><span class="cx">     [CallWith=Document] undefined withDocumentArgument();
</span><ins>+    [CallWith=RelevantDocument] undefined withRelevantDocumentArgument();
</ins><span class="cx">     [CallWith=IncumbentDocument] undefined withCallerDocumentArgument();
</span><span class="cx">     [CallWith=IncumbentWindow] undefined withCallerWindowArgument();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Event.idl (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Event.idl       2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/dom/Event.idl  2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     readonly attribute boolean composed;
</span><span class="cx"> 
</span><span class="cx">     [LegacyUnforgeable] readonly attribute boolean isTrusted;
</span><del>-    [CallWith=ScriptExecutionContext, ImplementedAs=timeStampForBindings] readonly attribute DOMHighResTimeStamp timeStamp;
</del><ins>+    [CallWith=RelevantScriptExecutionContext, ImplementedAs=timeStampForBindings] readonly attribute DOMHighResTimeStamp timeStamp;
</ins><span class="cx"> 
</span><span class="cx">     undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // Historical.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomIdleDeadlineidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/IdleDeadline.idl (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/IdleDeadline.idl        2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/dom/IdleDeadline.idl   2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -30,6 +30,6 @@
</span><span class="cx">     ImplementationLacksVTable,
</span><span class="cx">     Exposed=Window
</span><span class="cx"> ] interface IdleDeadline {
</span><del>-    [CallWith=Document] DOMHighResTimeStamp timeRemaining();
-    [CallWith=Document] readonly attribute boolean didTimeout;
</del><ins>+    [CallWith=RelevantDocument] DOMHighResTimeStamp timeRemaining();
+    [CallWith=RelevantDocument] readonly attribute boolean didTimeout;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp  2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/page/DOMWindow.cpp     2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -1794,7 +1794,7 @@
</span><span class="cx">     page->chrome().setWindowRect(adjustWindowRect(*page, update));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<int> DOMWindow::setTimeout(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</del><ins>+ExceptionOr<int> DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</ins><span class="cx"> {
</span><span class="cx">     RefPtr context = scriptExecutionContext();
</span><span class="cx">     if (!context)
</span><span class="lines">@@ -1802,7 +1802,7 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
</span><span class="cx">     if (action->type() == ScheduledAction::Type::Code) {
</span><del>-        if (!context->contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
</del><ins>+        if (!context->contentSecurityPolicy()->allowEval(context->globalObject(), LogToConsole::Yes))
</ins><span class="cx">             return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1819,7 +1819,7 @@
</span><span class="cx">     DOMTimer::removeById(*context, timeoutId);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<int> DOMWindow::setInterval(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</del><ins>+ExceptionOr<int> DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</ins><span class="cx"> {
</span><span class="cx">     RefPtr context = scriptExecutionContext();
</span><span class="cx">     if (!context)
</span><span class="lines">@@ -1827,7 +1827,7 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
</span><span class="cx">     if (action->type() == ScheduledAction::Type::Code) {
</span><del>-        if (!context->contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
</del><ins>+        if (!context->contentSecurityPolicy()->allowEval(context->globalObject(), LogToConsole::Yes))
</ins><span class="cx">             return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.h (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.h    2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/page/DOMWindow.h       2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -293,9 +293,9 @@
</span><span class="cx">     VisualViewport& visualViewport();
</span><span class="cx"> 
</span><span class="cx">     // Timers
</span><del>-    ExceptionOr<int> setTimeout(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</del><ins>+    ExceptionOr<int> setTimeout(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</ins><span class="cx">     void clearTimeout(int timeoutId);
</span><del>-    ExceptionOr<int> setInterval(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</del><ins>+    ExceptionOr<int> setInterval(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</ins><span class="cx">     void clearInterval(int timeoutId);
</span><span class="cx"> 
</span><span class="cx">     int requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
</span></span></pre></div>
<a id="trunkSourceWebCorepageHistoryidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/History.idl (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/History.idl    2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/page/History.idl       2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -33,9 +33,9 @@
</span><span class="cx">     attribute ScrollRestoration scrollRestoration;
</span><span class="cx">     [Custom] readonly attribute any state;
</span><span class="cx"> 
</span><del>-    [CallWith=Document] undefined back();
-    [CallWith=Document] undefined forward();
-    [CallWith=Document] undefined go(optional long delta = 0);
</del><ins>+    [CallWith=RelevantDocument] undefined back();
+    [CallWith=RelevantDocument] undefined forward();
+    [CallWith=RelevantDocument] undefined go(optional long delta = 0);
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: title should not be nullable as per the HTML specification.
</span><span class="cx">     undefined pushState(SerializedScriptValue data, DOMString? title, optional USVString? url = null);
</span></span></pre></div>
<a id="trunkSourceWebCorepageWindowOrWorkerGlobalScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp  2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp     2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -46,10 +46,10 @@
</span><span class="cx">     reportException(&globalObject, exception);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<JSC::JSValue> WindowOrWorkerGlobalScope::structuredClone(JSDOMGlobalObject& globalObject, JSC::JSValue value, StructuredSerializeOptions&& options)
</del><ins>+ExceptionOr<JSC::JSValue> WindowOrWorkerGlobalScope::structuredClone(JSDOMGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& relevantGlobalObject, JSC::JSValue value, StructuredSerializeOptions&& options)
</ins><span class="cx"> {
</span><span class="cx">     Vector<RefPtr<MessagePort>> ports;
</span><del>-    auto messageData = SerializedScriptValue::create(globalObject, value, WTFMove(options.transfer), ports, SerializationContext::WindowPostMessage);
</del><ins>+    auto messageData = SerializedScriptValue::create(lexicalGlobalObject, value, WTFMove(options.transfer), ports, SerializationContext::WindowPostMessage);
</ins><span class="cx">     if (messageData.hasException())
</span><span class="cx">         return messageData.releaseException();
</span><span class="cx"> 
</span><span class="lines">@@ -58,10 +58,10 @@
</span><span class="cx">         return disentangledPorts.releaseException();
</span><span class="cx"> 
</span><span class="cx">     Vector<RefPtr<MessagePort>> entangledPorts;
</span><del>-    if (auto* scriptExecutionContext = globalObject.scriptExecutionContext())
</del><ins>+    if (auto* scriptExecutionContext = relevantGlobalObject.scriptExecutionContext())
</ins><span class="cx">         entangledPorts = MessagePort::entanglePorts(*scriptExecutionContext, disentangledPorts.releaseReturnValue());
</span><span class="cx"> 
</span><del>-    return messageData.returnValue()->deserialize(globalObject, &globalObject, WTFMove(entangledPorts));
</del><ins>+    return messageData.returnValue()->deserialize(lexicalGlobalObject, &relevantGlobalObject, WTFMove(entangledPorts));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageWindowOrWorkerGlobalScopeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.h (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.h    2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.h       2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> class WindowOrWorkerGlobalScope {
</span><span class="cx"> public:
</span><span class="cx">     static void reportError(JSDOMGlobalObject&, JSC::JSValue);
</span><del>-    static ExceptionOr<JSC::JSValue> structuredClone(JSDOMGlobalObject&, JSC::JSValue, StructuredSerializeOptions&&);
</del><ins>+    static ExceptionOr<JSC::JSValue> structuredClone(JSDOMGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& relevantGlobalObject, JSC::JSValue, StructuredSerializeOptions&&);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageWindowOrWorkerGlobalScopeidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.idl (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.idl  2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.idl     2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> 
</span><span class="cx">     [EnabledBySetting=CrossOriginOpenerPolicyEnabled] readonly attribute boolean crossOriginIsolated;
</span><span class="cx"> 
</span><del>-    [CallWith=GlobalObject] undefined reportError(any error);
</del><ins>+    [CallWith=RelevantGlobalObject] undefined reportError(any error);
</ins><span class="cx"> 
</span><span class="cx">     // Base64 utility methods.
</span><span class="cx">     DOMString atob(DOMString string);
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx"> 
</span><span class="cx">     // Timers.
</span><span class="cx">     // FIXME: This should take a TimerHandler (a.k.a. (DOMString or Function)) rather than a ScheduledAction.
</span><del>-    [CallWith=GlobalObject] long setTimeout(ScheduledAction handler, optional long timeout = 0, any... arguments);
</del><ins>+    long setTimeout(ScheduledAction handler, optional long timeout = 0, any... arguments);
</ins><span class="cx">     undefined clearTimeout(optional long handle = 0);
</span><span class="cx">     // FIXME: This should take a TimerHandler (a.k.a. (DOMString or Function)) rather than a ScheduledAction.
</span><del>-    [CallWith=GlobalObject] long setInterval(ScheduledAction handler, optional long timeout = 0, any... arguments);
</del><ins>+    long setInterval(ScheduledAction handler, optional long timeout = 0, any... arguments);
</ins><span class="cx">     undefined clearInterval(optional long handle = 0);
</span><span class="cx"> 
</span><span class="cx">     // microtask queuing.
</span><span class="lines">@@ -71,5 +71,5 @@
</span><span class="cx">     [EnabledAtRuntime=ImageBitmapEnabled] Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
</span><span class="cx"> 
</span><span class="cx">     // structured cloning
</span><del>-    [CallWith=GlobalObject] any structuredClone(any value, optional StructuredSerializeOptions options);
</del><ins>+    [CallWith=GlobalObject&RelevantGlobalObject] any structuredClone(any value, optional StructuredSerializeOptions options);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersWorkerGlobalScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp       2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp  2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -302,11 +302,11 @@
</span><span class="cx">         m_navigator->setIsOnline(isOnline);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<int> WorkerGlobalScope::setTimeout(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</del><ins>+ExceptionOr<int> WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
</span><span class="cx">     if (action->type() == ScheduledAction::Type::Code) {
</span><del>-        if (!contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
</del><ins>+        if (!contentSecurityPolicy()->allowEval(globalObject(), LogToConsole::Yes))
</ins><span class="cx">             return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -320,11 +320,11 @@
</span><span class="cx">     DOMTimer::removeById(*this, timeoutId);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<int> WorkerGlobalScope::setInterval(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</del><ins>+ExceptionOr<int> WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
</span><span class="cx">     if (action->type() == ScheduledAction::Type::Code) {
</span><del>-        if (!contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
</del><ins>+        if (!contentSecurityPolicy()->allowEval(globalObject(), LogToConsole::Yes))
</ins><span class="cx">             return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersWorkerGlobalScopeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (286894 => 286895)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/WorkerGlobalScope.h 2021-12-11 02:06:54 UTC (rev 286894)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h    2021-12-11 02:26:37 UTC (rev 286895)
</span><span class="lines">@@ -112,9 +112,9 @@
</span><span class="cx"> 
</span><span class="cx">     void setIsOnline(bool);
</span><span class="cx"> 
</span><del>-    ExceptionOr<int> setTimeout(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</del><ins>+    ExceptionOr<int> setTimeout(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</ins><span class="cx">     void clearTimeout(int timeoutId);
</span><del>-    ExceptionOr<int> setInterval(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</del><ins>+    ExceptionOr<int> setInterval(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
</ins><span class="cx">     void clearInterval(int timeoutId);
</span><span class="cx"> 
</span><span class="cx">     bool isSecureContext() const final;
</span></span></pre>
</div>
</div>

</body>
</html>