Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript ShadowRealm proposal integration #9893

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open

Conversation

Ms2ger
Copy link
Member

@Ms2ger Ms2ger commented Oct 30, 2023

To replace #5339.

(See WHATWG Working Mode: Changes for more details.)

TODO:

  • Prepare PRs for dependent specs to adjust to terminology changes

/browsing-the-web.html ( diff )
/dom.html ( diff )
/embedded-content.html ( diff )
/form-elements.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/media.html ( diff )
/nav-history-apis.html ( diff )
/references.html ( diff )
/scripting.html ( diff )
/structured-data.html ( diff )
/timers-and-user-prompts.html ( diff )
/webappapis.html ( diff )
/workers.html ( diff )

Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to the module loading algorithms look ok.

For the record, we (people working on modules in TC39) have some ideas for splitting the stateless and stateful parts of Module Records in ECMA-262. If/once that will happen, it would be great to share a module map for the stateless parts across principal realms and shadow realms, so that basically in this case:

import "/foo";
new ShadowRealm().importValue("/foo", "bar");

we only call into fetch once (to get the stateless part) and then we create the stateful part twice in both realms.

source Outdated Show resolved Hide resolved
@Ms2ger Ms2ger marked this pull request as ready for review February 2, 2024 15:10
@Ms2ger
Copy link
Member Author

Ms2ger commented Feb 2, 2024

I think this could benefit from review at this point

ptomato added a commit to ptomato/whatwg-dom that referenced this pull request Feb 7, 2024
Delete the Exposed attribute from AbortSignal.timeout, letting it
inherit [Exposed=*] from AbortSignal.

Cf. whatwg/html#9893 where other timers are
being exposed in ShadowRealm global contexts.
@littledan
Copy link
Contributor

littledan commented Feb 7, 2024

ShadowRealms reached 2.7 in TC39. Acceptance of this PR by WHATWG editors is a blocking requirement for Stage 3, though it probably shouldn't be landed until the Web API set is finalized.

@domenic @annevk @zcorpan Any thoughts/concerns?

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@Ms2ger
Copy link
Member Author

Ms2ger commented Oct 8, 2024

@domenic or @annevk - it seems to me that the we're making progress on the questions about exposure; is there anything else I can do to help move this PR forward?

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
shannonbooth added a commit to shannonbooth/ladybird that referenced this pull request Oct 23, 2024
This aligns with the lastest version of the PR implementing the
javascript shadow realm proposal:

whatwg/html#9893

This commit simply performs the rename before implementing the behaviour
change.
source Outdated Show resolved Hide resolved
ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this pull request Nov 22, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108
<h6>Creating a Shadow Realm</h6>

<p>When performing <span data-x="js-InitializeHostDefinedRealm">InitializeHostDefinedRealm</span>
in the <code data-x="js-ShadowRealm-constructor">ShadowRealm</code> constructor, the steps to
Copy link
Contributor

@shannonbooth shannonbooth Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally preferred the old steps for global object creation before dc9fddc as the steps if followed explicitly were more easily implementable without needing to add web specific changes into the javascript implementation. There is no clear hook for InitializeHostDefinedRealm to say that it is being invoked in the ShadowRealm constructor.

I think this type of customization should ideally be explicitly stated at the call site of HostInitializeShadowRealm, similar to how https://whatpr.org/html/9893/webappapis.html#creating-a-new-javascript-realm does where it is used like:

Let realm execution context be the result of creating a new realm given agent and the following customizations:

For the global object, create a new Window object.

For the global this binding, use browsingContext's WindowProxy object.

What makes this awkward is that HostInitializeShadowRealm is being invoked in JS spec, where we would like to make that customization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not great in terms of layering. I'm hoping tc39/ecma262#3497 and tc39/ecma262#3274 will get us somewhere better, and then we can do an editorial change to adjust to that.

source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Nov 26, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108

UltraBlame original commit: 0a625225a525e60a048bbd6f3a94e2605c7e375b
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Nov 27, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108

UltraBlame original commit: 0a625225a525e60a048bbd6f3a94e2605c7e375b
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Nov 27, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108

UltraBlame original commit: 0a625225a525e60a048bbd6f3a94e2605c7e375b
@@ -111504,7 +111504,8 @@ interface <dfn interface>ShadowRealmGlobalScope</dfn> : <span>EventTarget</span>

<li><p>Set <var>settings</var>'s <span
data-x="synthetic-realm-settings-object-principal-realm">principal realm</span> to <var>O</var>'s
<span>associated realm</span>.</p></li>
<span>associated realm</span>'s
<span data-x="concept-principal-realm-of-realm">principal realm</span>.</p></li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we still run into an issue here if there is a third layer of shadow realm nesting?

My thinking is that this should effectively be a while loop which will go up until it sees that the host defined is not a synthetic settings object. Then, principal-realm-of-realm does not need to worry about how many layers of nesting of shadow realms there are.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppose a principal realm X → ShadowRealm A → ShadowRealm B → ShadowRealm C.

  • Creating A: O's associated realm is X, so we set A.[[HostDefined]]'s synthetic-realm-settings-object-principal-realm to X's concept-principal-realm-of-realm which is also X
  • Creating B: O's associated realm is A, and A's concept-principal-realm-of-realm is A.[[HostDefined]]'s synthetic-realm-settings-object-principal-realm, which is X, and we set B.[[HostDefined]]'s synthetic-realm-settings-object-principal-realm to X.
  • Creating C: O's associated realm is B, and B's concept-principal-realm-of-realm is B.[[HostDefined]]'s synthetic-realm-settings-object-principal-realm, which is X, etc.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Nov 27, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Nov 30, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Dec 1, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108

UltraBlame original commit: 6e028bd2e67651237d696535280054f7c544f251
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Dec 1, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108

UltraBlame original commit: 6e028bd2e67651237d696535280054f7c544f251
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Dec 1, 2024
…, a=testonly

Automatic update from web-platform-tests
Change 'shadowrealm' global into a shorthand for all possible ShadowRealm scopes

In order to automatically run tests not only in a ShadowRealm created in a
window scope, but also in ShadowRealms created in other realms, change the
'shadowrealm' global type to a collection, and rename the existing
ShadowRealm handler to 'shadowrealm-in-window'.

--
Remove monkeypatch of globalThis.self in ShadowRealm

As per whatwg/html#9893, ShadowRealmGlobalScope
should have a `self` attribute already. There is no need to monkeypatch it
for the test harness.

--
Factor out JS code that will be common to multiple ShadowRealm handlers

We will add multiple ShadowRealm handlers, and they will all need to set
up certain global properties. Avoid repeating this code in each handler
as well as in idlharness-shadowrealm.js.

This should also increase readability, which is good since the ShadowRealm
setup code can be confusing.

--
Add 'shadowrealm-in-shadowrealm' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-shadowrealm.html variant.

The test wrapper creates an outer ShadowRealm, which creates an inner
ShadowRealm and runs the tests inside that, relaying the results through
the outer ShadowRealm.

--
Add 'shadowrealm-in-dedicatedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-dedicatedworker.html variant.

The test loads an intermediate .any.worker-shadowrealm.js wrapper into a
Worker, and forwards the message port to the Worker's message port so that
fetch_tests_from_worker can receive the results.

--
Add 'shadowrealm-in-sharedworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-sharedworker.html variant.

The test loads the same intermediate .any.worker-shadowrealm.js wrapper as
.any.shadowrealm-in-dedicatedworker.html, but populates a 'port' variable
with the port received from the connect event, instead of calling the
global postMessage since that won't work in a SharedWorker.

--
Add 'shadowrealm-in-serviceworker' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-serviceworker.html variant.

We have to use a slightly different .any.serviceworker-shadowrealm.js
wrapper from the wrapper used for the other types of workers, because
dynamic import() is forbidden in ServiceWorker scopes. Instead, add a
utility function to set up a fakeDynamicImport() function inside the
ShadowRealm which uses the fetch adaptor to get the module's source text
and evaluate it in the shadowRealm.

Also add a case for ServiceWorkers to getPostMessageFunc(), which returns
a postMessage() drop-in replacement that broadcasts the message to all
clients, since test result messages from the ShadowRealm are not in
response to any particular message received by the ServiceWorker.

Note '.https.' needs to be added to the test path.

--
Add 'shadowrealm-in-audioworklet' global

This will add to any test with global=shadowrealm in its metadata, an
.any.shadowrealm-in-audioworklet.html variant.

The wrapper here is similar to the one for ServiceWorkers, since dynamic
import() is also forbidden in worklet scopes. But additionally fetch() is
not exposed, so we add a utility function to set up the ability to call
the window realm's fetch() through the AudioWorklet's message port.

We also add /resources/testharness-shadowrealm-audioworkletprocessor.js to
contain most of the AudioWorklet setup boilerplate, so that it isn't
written inline in serve.py.

Note '.https.' needs to be added to the test path.

--

wpt-commits: 9c8db8af89efbe0f67b215af2a6b49e9564e2971, 65a205aea5d02ff5bea7b1a0579287035d02d6c4, eb9c8e7259ef8bd5cca5019c1ca15ccd430e81dc, 3a20c56893472783b5e20c0d61cbb7b7b278cc6d, 7d8458ed291b139307430a102180c9a617d7876e, 42160ae827c863ac6787c8451fe377901c8f0652, 59367bb21d053abb9ed6de3cca5409486816acc9, 60d6c48e5fa76876bc3924b9d6185dfb56c9ab1c
wpt-pr: 49108

UltraBlame original commit: 6e028bd2e67651237d696535280054f7c544f251
@past past added the needs implementer interest Moving the issue forward requires implementers to express interest label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs implementer interest Moving the issue forward requires implementers to express interest
Development

Successfully merging this pull request may close these issues.