Skip to content

Commit 36c2092

Browse files
committed
Bug 1930534 [wpt PR 49108] - Run ShadowRealm tests in multiple scopes, 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
1 parent 23264d8 commit 36c2092

File tree

7 files changed

+3235
-494
lines changed

7 files changed

+3235
-494
lines changed

testing/web-platform/tests/docs/writing-tests/testharness.md

+272
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,10 @@ worker
15441544
scopes
15451545
*
15461546
shadowrealm
1547+
-
1548+
in
1549+
-
1550+
window
15471551
:
15481552
runs
15491553
the
@@ -1596,12 +1600,280 @@ var
15961600
any
15971601
.
15981602
shadowrealm
1603+
-
1604+
in
1605+
-
1606+
window
1607+
.
1608+
html
1609+
<
1610+
/
1611+
code
1612+
>
1613+
*
1614+
shadowrealm
1615+
-
1616+
in
1617+
-
1618+
shadowrealm
1619+
:
1620+
runs
1621+
the
1622+
test
1623+
code
1624+
in
1625+
a
1626+
ShadowRealm
1627+
context
1628+
hosted
1629+
in
1630+
another
1631+
ShadowRealm
1632+
context
1633+
;
1634+
to
1635+
be
1636+
run
1637+
at
1638+
<
1639+
code
1640+
>
1641+
<
1642+
var
1643+
>
1644+
x
1645+
<
1646+
/
1647+
var
1648+
>
1649+
.
1650+
any
1651+
.
1652+
shadowrealm
1653+
-
1654+
in
1655+
-
1656+
shadowrealm
1657+
.
1658+
html
1659+
<
1660+
/
1661+
code
1662+
>
1663+
*
1664+
shadowrealm
1665+
-
1666+
in
1667+
-
1668+
dedicatedworker
1669+
:
1670+
runs
1671+
the
1672+
test
1673+
code
1674+
in
1675+
a
1676+
ShadowRealm
1677+
context
1678+
hosted
1679+
in
1680+
a
1681+
dedicated
1682+
worker
1683+
;
1684+
to
1685+
be
1686+
run
1687+
at
1688+
<
1689+
code
1690+
>
1691+
<
1692+
var
1693+
>
1694+
x
1695+
<
1696+
/
1697+
var
1698+
>
1699+
.
1700+
any
1701+
.
1702+
shadowrealm
1703+
-
1704+
in
1705+
-
1706+
dedicatedworker
15991707
.
16001708
html
16011709
<
16021710
/
16031711
code
16041712
>
1713+
*
1714+
shadowrealm
1715+
-
1716+
in
1717+
-
1718+
sharedworker
1719+
:
1720+
runs
1721+
the
1722+
test
1723+
code
1724+
in
1725+
a
1726+
ShadowRealm
1727+
context
1728+
hosted
1729+
in
1730+
a
1731+
shared
1732+
worker
1733+
;
1734+
to
1735+
be
1736+
run
1737+
at
1738+
<
1739+
code
1740+
>
1741+
<
1742+
var
1743+
>
1744+
x
1745+
<
1746+
/
1747+
var
1748+
>
1749+
.
1750+
any
1751+
.
1752+
shadowrealm
1753+
-
1754+
in
1755+
-
1756+
sharedworker
1757+
.
1758+
html
1759+
<
1760+
/
1761+
code
1762+
>
1763+
*
1764+
shadowrealm
1765+
-
1766+
in
1767+
-
1768+
serviceworker
1769+
:
1770+
runs
1771+
the
1772+
test
1773+
code
1774+
in
1775+
a
1776+
ShadowRealm
1777+
context
1778+
hosted
1779+
in
1780+
a
1781+
service
1782+
worker
1783+
;
1784+
to
1785+
be
1786+
run
1787+
at
1788+
<
1789+
code
1790+
>
1791+
<
1792+
var
1793+
>
1794+
x
1795+
<
1796+
/
1797+
var
1798+
>
1799+
.
1800+
https
1801+
.
1802+
any
1803+
.
1804+
shadowrealm
1805+
-
1806+
in
1807+
-
1808+
serviceworker
1809+
.
1810+
html
1811+
<
1812+
/
1813+
code
1814+
>
1815+
*
1816+
shadowrealm
1817+
-
1818+
in
1819+
-
1820+
audioworklet
1821+
:
1822+
runs
1823+
the
1824+
test
1825+
code
1826+
in
1827+
a
1828+
ShadowRealm
1829+
context
1830+
hosted
1831+
in
1832+
an
1833+
AudioWorklet
1834+
processor
1835+
;
1836+
to
1837+
be
1838+
run
1839+
at
1840+
<
1841+
code
1842+
>
1843+
<
1844+
var
1845+
>
1846+
x
1847+
<
1848+
/
1849+
var
1850+
>
1851+
.
1852+
https
1853+
.
1854+
any
1855+
.
1856+
shadowrealm
1857+
-
1858+
in
1859+
-
1860+
audioworklet
1861+
.
1862+
html
1863+
<
1864+
/
1865+
code
1866+
>
1867+
*
1868+
shadowrealm
1869+
:
1870+
shorthand
1871+
for
1872+
all
1873+
of
1874+
the
1875+
ShadowRealm
1876+
scopes
16051877
To
16061878
check
16071879
what

0 commit comments

Comments
 (0)