Title: [286895] trunk
Revision
286895
Author
commit-qu...@webkit.org
Date
2021-12-10 18:26:37 -0800 (Fri, 10 Dec 2021)

Log Message

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

Patch by Alexey Shvayka <ashva...@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)

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286894 => 286895)


--- 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)
@@ -1,5 +1,29 @@
 2021-12-10  Alexey Shvayka  <ashva...@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.
+
+        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  <ashva...@apple.com>
+
         Extend the scope where the Window's current event is set
         https://bugs.webkit.org/show_bug.cgi?id=233833
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter-expected.txt (0 => 286895)


--- 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)
@@ -0,0 +1,4 @@
+
+
+PASS event.timeStamp is initialized using event's relevant global object
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-cross-realm-getter.html (0 => 286895)


--- 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)
@@ -0,0 +1,27 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>event.timeStamp is initialized using event's relevant global object</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+
+<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>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method-expected.txt (0 => 286895)


--- 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)
@@ -0,0 +1,4 @@
+
+
+PASS history.back() uses this's associated document's browsing context to determine if navigation is allowed
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_back_cross_realm_method.html (0 => 286895)


--- 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)
@@ -0,0 +1,22 @@
+<!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=""
+<script src=""
+<script src=""
+
+<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>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method-expected.txt (0 => 286895)


--- 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)
@@ -0,0 +1,4 @@
+
+
+PASS history.forward() uses this's associated document's browsing context to determine if navigation is allowed
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_cross_realm_method.html (0 => 286895)


--- 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)
@@ -0,0 +1,28 @@
+<!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=""
+<script src=""
+<script src=""
+
+<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>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method-expected.txt (0 => 286895)


--- 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)
@@ -0,0 +1,4 @@
+
+
+PASS history.go() uses this's associated document's browsing context to determine if navigation is allowed
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_cross_realm_method.html (0 => 286895)


--- 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)
@@ -0,0 +1,23 @@
+<!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=""
+<script src=""
+<script src=""
+
+<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>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method-expected.txt (0 => 286895)


--- 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)
@@ -0,0 +1,5 @@
+CONSOLE MESSAGE: TypeError: foo
+
+
+PASS self.reportError() dispatches an "error" event for this's relevant global object
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/reporterror-cross-realm-method.html (0 => 286895)


--- 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)
@@ -0,0 +1,30 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>self.reportError() dispatches an "error" event for this's relevant global object</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+
+<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>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method-expected.txt (0 => 286895)


--- 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)
@@ -0,0 +1,7 @@
+
+
+PASS Object instance
+PASS Array instance
+PASS Date instance
+PASS RegExp instance
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone-cross-realm-method.html (0 => 286895)


--- 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)
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>self.structuredClone() uses this's relevant Realm for deserialization</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+
+<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>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method-expected.txt (0 => 286895)


--- 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)
@@ -0,0 +1,4 @@
+
+
+PASS IdleDeadline::timeRemaining() uses relevant global object as a high-res timestamp origin
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html (0 => 286895)


--- 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)
@@ -0,0 +1,25 @@
+<!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=""
+<script src=""
+<script src=""
+
+<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>

Modified: trunk/Source/WebCore/ChangeLog (286894 => 286895)


--- 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)
@@ -1,3 +1,82 @@
+2021-12-10  Alexey Shvayka  <ashva...@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)
+
 2021-12-10  Devin Rousso  <drou...@apple.com>
 
         WKWebView doesn’t respond to -copyFont: and -pasteFont:

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl (286894 => 286895)


--- 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)
@@ -27,10 +27,10 @@
     SkipVTableValidation,
     Exposed=(Window,Worker)
 ] interface IDBFactory {
-    [NewObject, CallWith=ScriptExecutionContext] IDBOpenDBRequest open(DOMString name, optional [EnforceRange] unsigned long long version);
-    [NewObject, CallWith=ScriptExecutionContext] IDBOpenDBRequest deleteDatabase(DOMString name);
+    [NewObject, CallWith=RelevantScriptExecutionContext] IDBOpenDBRequest open(DOMString name, optional [EnforceRange] unsigned long long version);
+    [NewObject, CallWith=RelevantScriptExecutionContext] IDBOpenDBRequest deleteDatabase(DOMString name);
     
-    [CallWith=ScriptExecutionContext] Promise<sequence<IDBDatabaseInfo>> databases();
+    [CallWith=RelevantScriptExecutionContext] Promise<sequence<IDBDatabaseInfo>> databases();
     
     [CallWith=GlobalObject] short cmp(any first, any second);
 };

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl (286894 => 286895)


--- 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)
@@ -33,9 +33,9 @@
 ] interface PaymentRequest : EventTarget {
     [CallWith=Document] constructor(sequence<PaymentMethodData> methodData, PaymentDetailsInit details, optional PaymentOptions options);
 
-    [CallWith=Document] Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise);
+    [CallWith=RelevantDocument] Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise);
     Promise<undefined> abort();
-    [CallWith=Document] Promise<boolean> canMakePayment();
+    [CallWith=RelevantDocument] Promise<boolean> canMakePayment();
 
     readonly attribute DOMString id;
     readonly attribute PaymentAddress? shippingAddress;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (286894 => 286895)


--- 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)
@@ -5936,9 +5936,16 @@
         push(@callWithArgs, "*${globalObject}");
         push(@callWithArgs, $callFrameReference);
     }
+    # Global object of current realm (https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything)
     if ($codeGenerator->ExtendedAttributeContains($callWith, "GlobalObject")) {
         push(@callWithArgs, "*${globalObject}");
     }
+    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)
     if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) {
         push(@$outputArray, $indent . "auto* context = ${scriptExecutionContextAccessor}->scriptExecutionContext();\n");
         push(@$outputArray, $indent . "if (UNLIKELY(!context))\n");
@@ -5945,6 +5952,14 @@
         push(@$outputArray, $indent . "    return" . ($contextMissing ? " " . $contextMissing : "") . ";\n");
         push(@callWithArgs, "*context");
     }
+    # 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)
     if ($codeGenerator->ExtendedAttributeContains($callWith, "Document")) {
         AddToImplIncludes("Document.h");
         push(@$outputArray, $indent . "auto* context = ${scriptExecutionContextAccessor}->scriptExecutionContext();\n");
@@ -5954,6 +5969,16 @@
         push(@$outputArray, $indent . "auto& document = downcast<Document>(*context);\n");
         push(@callWithArgs, "document");
     }
+    # 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");
+    }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "IncumbentDocument")) {
         AddToImplIncludes("DOMWindow.h");
         AddToImplIncludes("JSDOMWindowBase.h");

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (286894 => 286895)


--- 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)
@@ -51,7 +51,11 @@
         },
         "CallWith": {
             "contextsAllowed": ["attribute", "operation"],
-            "values": ["Document", "ExecState", "ScriptExecutionContext", "GlobalObject", "ActiveWindow", "FirstWindow", "EntryDocument", "World", "PropertyName"],
+            "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."
+            },
             "supportsConjunction": true
         },
         "CheckSecurity": {

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (286894 => 286895)


--- 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)
@@ -1520,11 +1520,14 @@
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_addEventListener);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_removeEventListener);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withExecStateVoid);
+static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantGlobalObjectVoid);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withExecStateObj);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withScriptExecutionContext);
+static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantScriptExecutionContext);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecState);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecStateWithSpaces);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withDocumentArgument);
+static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withRelevantDocumentArgument);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withCallerDocumentArgument);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_withCallerWindowArgument);
 static JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunction_methodWithOptionalArg);
@@ -2243,11 +2246,14 @@
     { "addEventListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_addEventListener), (intptr_t) (2) } },
     { "removeEventListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_removeEventListener), (intptr_t) (2) } },
     { "withExecStateVoid", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withExecStateVoid), (intptr_t) (0) } },
+    { "withRelevantGlobalObjectVoid", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withRelevantGlobalObjectVoid), (intptr_t) (0) } },
     { "withExecStateObj", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withExecStateObj), (intptr_t) (0) } },
     { "withScriptExecutionContext", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withScriptExecutionContext), (intptr_t) (0) } },
+    { "withRelevantScriptExecutionContext", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withRelevantScriptExecutionContext), (intptr_t) (0) } },
     { "withScriptExecutionContextAndExecState", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecState), (intptr_t) (0) } },
     { "withScriptExecutionContextAndExecStateWithSpaces", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withScriptExecutionContextAndExecStateWithSpaces), (intptr_t) (0) } },
     { "withDocumentArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withDocumentArgument), (intptr_t) (0) } },
+    { "withRelevantDocumentArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withRelevantDocumentArgument), (intptr_t) (0) } },
     { "withCallerDocumentArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withCallerDocumentArgument), (intptr_t) (0) } },
     { "withCallerWindowArgument", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_withCallerWindowArgument), (intptr_t) (0) } },
     { "methodWithOptionalArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunction_methodWithOptionalArg), (intptr_t) (0) } },
@@ -6220,6 +6226,21 @@
     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withExecStateVoidBody>(*lexicalGlobalObject, *callFrame, "withExecStateVoid");
 }
 
+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");
+}
+
 static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withExecStateObjBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
 {
     auto& vm = JSC::getVM(lexicalGlobalObject);
@@ -6253,6 +6274,24 @@
     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withScriptExecutionContextBody>(*lexicalGlobalObject, *callFrame, "withScriptExecutionContext");
 }
 
+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");
+}
+
 static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withScriptExecutionContextAndExecStateBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
 {
     auto& vm = JSC::getVM(lexicalGlobalObject);
@@ -6309,6 +6348,26 @@
     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunction_withDocumentArgumentBody>(*lexicalGlobalObject, *callFrame, "withDocumentArgument");
 }
 
+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");
+}
+
 static inline JSC::EncodedJSValue jsTestObjPrototypeFunction_withCallerDocumentArgumentBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
 {
     auto& vm = JSC::getVM(lexicalGlobalObject);

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (286894 => 286895)


--- 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)
@@ -190,11 +190,14 @@
 
     // 'CallWith' extended attribute
     [CallWith=GlobalObject] undefined withExecStateVoid();
+    [CallWith=RelevantGlobalObject] undefined withRelevantGlobalObjectVoid();
     [CallWith=GlobalObject] TestObj withExecStateObj();
     [CallWith=ScriptExecutionContext] undefined withScriptExecutionContext();
+    [CallWith=RelevantScriptExecutionContext] undefined withRelevantScriptExecutionContext();
     [CallWith=ScriptExecutionContext&ExecState] undefined withScriptExecutionContextAndExecState();
     [CallWith=  ScriptExecutionContext  &  ExecState  ] TestObj withScriptExecutionContextAndExecStateWithSpaces();
     [CallWith=Document] undefined withDocumentArgument();
+    [CallWith=RelevantDocument] undefined withRelevantDocumentArgument();
     [CallWith=IncumbentDocument] undefined withCallerDocumentArgument();
     [CallWith=IncumbentWindow] undefined withCallerWindowArgument();
 

Modified: trunk/Source/WebCore/dom/Event.idl (286894 => 286895)


--- 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)
@@ -51,7 +51,7 @@
     readonly attribute boolean composed;
 
     [LegacyUnforgeable] readonly attribute boolean isTrusted;
-    [CallWith=ScriptExecutionContext, ImplementedAs=timeStampForBindings] readonly attribute DOMHighResTimeStamp timeStamp;
+    [CallWith=RelevantScriptExecutionContext, ImplementedAs=timeStampForBindings] readonly attribute DOMHighResTimeStamp timeStamp;
 
     undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // Historical.
 

Modified: trunk/Source/WebCore/dom/IdleDeadline.idl (286894 => 286895)


--- 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)
@@ -30,6 +30,6 @@
     ImplementationLacksVTable,
     Exposed=Window
 ] interface IdleDeadline {
-    [CallWith=Document] DOMHighResTimeStamp timeRemaining();
-    [CallWith=Document] readonly attribute boolean didTimeout;
+    [CallWith=RelevantDocument] DOMHighResTimeStamp timeRemaining();
+    [CallWith=RelevantDocument] readonly attribute boolean didTimeout;
 };

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (286894 => 286895)


--- 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)
@@ -1794,7 +1794,7 @@
     page->chrome().setWindowRect(adjustWindowRect(*page, update));
 }
 
-ExceptionOr<int> DOMWindow::setTimeout(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
+ExceptionOr<int> DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
 {
     RefPtr context = scriptExecutionContext();
     if (!context)
@@ -1802,7 +1802,7 @@
 
     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
     if (action->type() == ScheduledAction::Type::Code) {
-        if (!context->contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
+        if (!context->contentSecurityPolicy()->allowEval(context->globalObject(), LogToConsole::Yes))
             return 0;
     }
 
@@ -1819,7 +1819,7 @@
     DOMTimer::removeById(*context, timeoutId);
 }
 
-ExceptionOr<int> DOMWindow::setInterval(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
+ExceptionOr<int> DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
 {
     RefPtr context = scriptExecutionContext();
     if (!context)
@@ -1827,7 +1827,7 @@
 
     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
     if (action->type() == ScheduledAction::Type::Code) {
-        if (!context->contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
+        if (!context->contentSecurityPolicy()->allowEval(context->globalObject(), LogToConsole::Yes))
             return 0;
     }
 

Modified: trunk/Source/WebCore/page/DOMWindow.h (286894 => 286895)


--- 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)
@@ -293,9 +293,9 @@
     VisualViewport& visualViewport();
 
     // Timers
-    ExceptionOr<int> setTimeout(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
+    ExceptionOr<int> setTimeout(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
     void clearTimeout(int timeoutId);
-    ExceptionOr<int> setInterval(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
+    ExceptionOr<int> setInterval(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
     void clearInterval(int timeoutId);
 
     int requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);

Modified: trunk/Source/WebCore/page/History.idl (286894 => 286895)


--- 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)
@@ -33,9 +33,9 @@
     attribute ScrollRestoration scrollRestoration;
     [Custom] readonly attribute any state;
 
-    [CallWith=Document] undefined back();
-    [CallWith=Document] undefined forward();
-    [CallWith=Document] undefined go(optional long delta = 0);
+    [CallWith=RelevantDocument] undefined back();
+    [CallWith=RelevantDocument] undefined forward();
+    [CallWith=RelevantDocument] undefined go(optional long delta = 0);
 
     // FIXME: title should not be nullable as per the HTML specification.
     undefined pushState(SerializedScriptValue data, DOMString? title, optional USVString? url = ""

Modified: trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp (286894 => 286895)


--- 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)
@@ -46,10 +46,10 @@
     reportException(&globalObject, exception);
 }
 
-ExceptionOr<JSC::JSValue> WindowOrWorkerGlobalScope::structuredClone(JSDOMGlobalObject& globalObject, JSC::JSValue value, StructuredSerializeOptions&& options)
+ExceptionOr<JSC::JSValue> WindowOrWorkerGlobalScope::structuredClone(JSDOMGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& relevantGlobalObject, JSC::JSValue value, StructuredSerializeOptions&& options)
 {
     Vector<RefPtr<MessagePort>> ports;
-    auto messageData = SerializedScriptValue::create(globalObject, value, WTFMove(options.transfer), ports, SerializationContext::WindowPostMessage);
+    auto messageData = SerializedScriptValue::create(lexicalGlobalObject, value, WTFMove(options.transfer), ports, SerializationContext::WindowPostMessage);
     if (messageData.hasException())
         return messageData.releaseException();
 
@@ -58,10 +58,10 @@
         return disentangledPorts.releaseException();
 
     Vector<RefPtr<MessagePort>> entangledPorts;
-    if (auto* scriptExecutionContext = globalObject.scriptExecutionContext())
+    if (auto* scriptExecutionContext = relevantGlobalObject.scriptExecutionContext())
         entangledPorts = MessagePort::entanglePorts(*scriptExecutionContext, disentangledPorts.releaseReturnValue());
 
-    return messageData.returnValue()->deserialize(globalObject, &globalObject, WTFMove(entangledPorts));
+    return messageData.returnValue()->deserialize(lexicalGlobalObject, &relevantGlobalObject, WTFMove(entangledPorts));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.h (286894 => 286895)


--- 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)
@@ -39,7 +39,7 @@
 class WindowOrWorkerGlobalScope {
 public:
     static void reportError(JSDOMGlobalObject&, JSC::JSValue);
-    static ExceptionOr<JSC::JSValue> structuredClone(JSDOMGlobalObject&, JSC::JSValue, StructuredSerializeOptions&&);
+    static ExceptionOr<JSC::JSValue> structuredClone(JSDOMGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& relevantGlobalObject, JSC::JSValue, StructuredSerializeOptions&&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.idl (286894 => 286895)


--- 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)
@@ -49,7 +49,7 @@
 
     [EnabledBySetting=CrossOriginOpenerPolicyEnabled] readonly attribute boolean crossOriginIsolated;
 
-    [CallWith=GlobalObject] undefined reportError(any error);
+    [CallWith=RelevantGlobalObject] undefined reportError(any error);
 
     // Base64 utility methods.
     DOMString atob(DOMString string);
@@ -57,10 +57,10 @@
 
     // Timers.
     // FIXME: This should take a TimerHandler (a.k.a. (DOMString or Function)) rather than a ScheduledAction.
-    [CallWith=GlobalObject] long setTimeout(ScheduledAction handler, optional long timeout = 0, any... arguments);
+    long setTimeout(ScheduledAction handler, optional long timeout = 0, any... arguments);
     undefined clearTimeout(optional long handle = 0);
     // FIXME: This should take a TimerHandler (a.k.a. (DOMString or Function)) rather than a ScheduledAction.
-    [CallWith=GlobalObject] long setInterval(ScheduledAction handler, optional long timeout = 0, any... arguments);
+    long setInterval(ScheduledAction handler, optional long timeout = 0, any... arguments);
     undefined clearInterval(optional long handle = 0);
 
     // microtask queuing.
@@ -71,5 +71,5 @@
     [EnabledAtRuntime=ImageBitmapEnabled] Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
 
     // structured cloning
-    [CallWith=GlobalObject] any structuredClone(any value, optional StructuredSerializeOptions options);
+    [CallWith=GlobalObject&RelevantGlobalObject] any structuredClone(any value, optional StructuredSerializeOptions options);
 };

Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (286894 => 286895)


--- 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)
@@ -302,11 +302,11 @@
         m_navigator->setIsOnline(isOnline);
 }
 
-ExceptionOr<int> WorkerGlobalScope::setTimeout(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
+ExceptionOr<int> WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
 {
     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
     if (action->type() == ScheduledAction::Type::Code) {
-        if (!contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
+        if (!contentSecurityPolicy()->allowEval(globalObject(), LogToConsole::Yes))
             return 0;
     }
 
@@ -320,11 +320,11 @@
     DOMTimer::removeById(*this, timeoutId);
 }
 
-ExceptionOr<int> WorkerGlobalScope::setInterval(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
+ExceptionOr<int> WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
 {
     // FIXME: Should this check really happen here? Or should it happen when code is about to eval?
     if (action->type() == ScheduledAction::Type::Code) {
-        if (!contentSecurityPolicy()->allowEval(&state, LogToConsole::Yes))
+        if (!contentSecurityPolicy()->allowEval(globalObject(), LogToConsole::Yes))
             return 0;
     }
 

Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (286894 => 286895)


--- 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)
@@ -112,9 +112,9 @@
 
     void setIsOnline(bool);
 
-    ExceptionOr<int> setTimeout(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
+    ExceptionOr<int> setTimeout(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
     void clearTimeout(int timeoutId);
-    ExceptionOr<int> setInterval(JSC::JSGlobalObject&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
+    ExceptionOr<int> setInterval(std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
     void clearInterval(int timeoutId);
 
     bool isSecureContext() const final;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to