mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 02:37:41 -05:00
[Worker support] test for no cors headers (#1374)
* test for no cors headers * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix tests * suggested changes * disable directly * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add error message * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * improve test * improve error message * remove py-config tag from cors test --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,30 @@ class TestBasic(PyScriptTest):
|
||||
expected = f"[pyscript/main] Starting the interpreter in {where}"
|
||||
assert expected in self.console.info.lines
|
||||
|
||||
def test_no_cors_headers(self):
|
||||
self.disable_cors_headers()
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<!-- we don't really need anything here, we just want to check that
|
||||
pyscript starts -->
|
||||
""",
|
||||
wait_for_pyscript=False,
|
||||
)
|
||||
assert self.headers == {}
|
||||
if self.execution_thread == "worker":
|
||||
expected_alert_banner_msg = (
|
||||
'(PY1000): When execution_thread is "worker", the site must be cross origin '
|
||||
"isolated, but crossOriginIsolated is false. To be cross origin isolated, "
|
||||
"the server must use https and also serve with the following headers: "
|
||||
'{"Cross-Origin-Embedder-Policy":"require-corp",'
|
||||
'"Cross-Origin-Opener-Policy":"same-origin"}. '
|
||||
"The problem may be that one or both of these are missing."
|
||||
)
|
||||
alert_banner = self.page.wait_for_selector(".alert-banner")
|
||||
assert expected_alert_banner_msg in alert_banner.inner_text()
|
||||
else:
|
||||
self.assert_no_banners()
|
||||
|
||||
def test_print(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user