summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_desktop_shell.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_desktop_shell.py')
-rw-r--r--packages/meshbay-hub/tests/test_desktop_shell.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_desktop_shell.py b/packages/meshbay-hub/tests/test_desktop_shell.py
index 7a26dfb..587103f 100644
--- a/packages/meshbay-hub/tests/test_desktop_shell.py
+++ b/packages/meshbay-hub/tests/test_desktop_shell.py
@@ -72,6 +72,24 @@ def test_navigation_away_from_the_package_is_refused():
assert "event.preventDefault()" in source
+def test_only_web_and_mail_links_reach_the_system():
+ """`shell.openExternal` hands a URL to whatever the system registered for
+ its scheme, so the handler names the schemes it passes: the web, and
+ `mailto:` for the recovery screen's "e-mail it to myself" (§3.6). A
+ `file:` or a custom scheme from the page would run a local program."""
+ import subprocess
+ source = _main()
+ block = source[source.index("setWindowOpenHandler"):]
+ block = block[:block.index("});")]
+ match = re.search(r"if \((/[^/]+/)\.test\(new URL\(url\)\.protocol\)\) shell\.openExternal\(url\)", block)
+ assert match, block
+ probe = ("const re = " + match.group(1) + ";"
+ "process.stdout.write(JSON.stringify(['https:','http:','mailto:','file:',"
+ "'javascript:','smb:','ms-settings:','vbscript:'].filter(p => re.test(p))))")
+ out = subprocess.run(["node", "-e", probe], capture_output=True, text=True, check=True)
+ assert json.loads(out.stdout) == ["https:", "http:", "mailto:"]
+
+
def _granted_permissions() -> set[str]:
"""The allowlist, read out of the source rather than described here."""
match = re.search(r"GRANTED_PERMISSIONS = new Set\(\[([^\]]*)\]\)", _main())