Skip to content

Commit

Permalink
Change 'shadowrealm' global into a shorthand for all possible ShadowR…
Browse files Browse the repository at this point in the history
…ealm 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'.
  • Loading branch information
ptomato committed Nov 18, 2024
1 parent bfd44a5 commit 95af5c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docs/writing-tests/testharness.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ are:
* `jsshell`: to be run in a JavaScript shell, without access to the DOM
(currently only supported in SpiderMonkey, and skipped in wptrunner)
* `worker`: shorthand for the dedicated, shared, and service worker scopes
* `shadowrealm`: runs the test code in a
* `shadowrealm-in-window`: runs the test code in a
[ShadowRealm](https://github.com/tc39/proposal-shadowrealm) context hosted in
an ordinary Window context; to be run at <code><var>x</var>.any.shadowrealm.html</code>
an ordinary Window context; to be run at <code><var>x</var>.any.shadowrealm-in-window.html</code>
* `shadowrealm`: shorthand for all of the ShadowRealm scopes

To check what scope your test is run from, you can use the following methods that will
be made available by the framework:
Expand Down
3 changes: 2 additions & 1 deletion tools/manifest/sourcefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class VariantData(TypedDict, total=False):
"dedicatedworker-module": {"suffix": ".any.worker-module.html"},
"worker": {"longhand": {"dedicatedworker", "sharedworker", "serviceworker"}},
"worker-module": {},
"shadowrealm": {},
"shadowrealm-in-window": {},
"shadowrealm": {"longhand": {"shadowrealm-in-window"}},
"jsshell": {"suffix": ".any.js"},
}

Expand Down
9 changes: 5 additions & 4 deletions tools/serve/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ class ServiceWorkerModulesHandler(HtmlWrapperHandler):
</script>
"""

class ShadowRealmHandler(HtmlWrapperHandler):
global_type = "shadowrealm"
path_replace = [(".any.shadowrealm.html", ".any.js")]

class ShadowRealmInWindowHandler(HtmlWrapperHandler):
global_type = "shadowrealm-in-window"
path_replace = [(".any.shadowrealm-in-window.html", ".any.js")]

wrapper = """<!doctype html>
<meta charset=utf-8>
Expand Down Expand Up @@ -590,7 +591,7 @@ def add_mount_point(self, url_base, path):
("GET", "*.any.sharedworker-module.html", SharedWorkerModulesHandler),
("GET", "*.any.serviceworker.html", ServiceWorkersHandler),
("GET", "*.any.serviceworker-module.html", ServiceWorkerModulesHandler),
("GET", "*.any.shadowrealm.html", ShadowRealmHandler),
("GET", "*.any.shadowrealm-in-window.html", ShadowRealmInWindowHandler),
("GET", "*.any.window-module.html", WindowModulesHandler),
("GET", "*.any.worker.js", ClassicWorkerHandler),
("GET", "*.any.worker-module.js", ModuleWorkerHandler),
Expand Down

0 comments on commit 95af5c9

Please sign in to comment.