Skip to content

Commit

Permalink
Add infrastructure for testing origin policy
Browse files Browse the repository at this point in the history
This adds 99 new subdomains for testing origin policy on, without interfering with other tests. It also configures `/.well-known/origin-policy` to use a Python script handler, instead of a static file handler, to allow varying responses. Closes #20773.

RFC: web-platform-tests/rfcs#44
  • Loading branch information
domenic committed Feb 18, 2020
1 parent cd20c3f commit 9403b42
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/serve/serve.py
Expand Up @@ -366,6 +366,7 @@ def add_mount_point(self, url_base, path):
("GET", "*.any.serviceworker.html", ServiceWorkersHandler),
("GET", "*.any.worker.js", AnyWorkerHandler),
("GET", "*.asis", handlers.AsIsHandler),
("GET", "/.well-known/origin-policy", handlers.PythonScriptHandler),
("*", "*.py", handlers.PythonScriptHandler),
("GET", "*", handlers.FileHandler)
]
Expand Down Expand Up @@ -742,6 +743,9 @@ def build_config(override_path=None, **kwargs):
def _make_subdomains_product(s, depth=2):
return {u".".join(x) for x in chain(*(product(s, repeat=i) for i in range(1, depth+1)))}

def _make_origin_policy_subdomains(limit):
return {u"op%d" % x for x in range(1,limit)}


_subdomains = {u"www",
u"www1",
Expand All @@ -753,6 +757,12 @@ def _make_subdomains_product(s, depth=2):

_subdomains = _make_subdomains_product(_subdomains)

# Origin policy subdomains need to not be reused by any other tests, since origin policies have
# origin-wide impacts like installing a CSP or Feature Policy that could interfere with features
# under test.
# See https://github.com/web-platform-tests/rfcs/pull/44.
_subdomains |= _make_origin_policy_subdomains(99)

_not_subdomains = _make_subdomains_product(_not_subdomains)


Expand Down

0 comments on commit 9403b42

Please sign in to comment.