More plugins: splashscreen and importmap (#938)

This PR move codes from main.ts into two new plugins:

- splashscreen (formerly known as py-loader)
- importmap

The old setting config.autoclose_loader is still supported but deprecated; the new setting is config.splashscreen.autoclose.

Moreover, it does a small refactoring around UserError: now UserErrors are correctly caught even if they are raised from within afterRuntimeLoad.
This commit is contained in:
Antonio Cuni
2022-11-16 18:08:17 +01:00
committed by GitHub
parent b79ceea7a8
commit 41ebaaf366
19 changed files with 498 additions and 284 deletions

View File

@@ -5,7 +5,7 @@ import tempfile
import pytest
import requests
from .support import JsErrors, PyScriptTest
from .support import PyScriptTest
URL = "https://github.com/pyodide/pyodide/releases/download/0.20.0/pyodide-build-0.20.0.tar.bz2"
TAR_NAME = "pyodide-build-0.20.0.tar.bz2"
@@ -245,30 +245,20 @@ class TestConfig(PyScriptTest):
wait_for_pyscript=False,
)
# This is expected if running pytest with --dev flag
localErrorContent = """PyScript: Access to local files
if self.is_fake_server:
expected = """PyScript: Access to local files
(using "Paths:" in <py-config>)
is not available when directly opening a HTML file;
you must use a webserver to serve the additional files."""
# This is expected if running a live server
serverErrorContent = (
"Loading from file <u>./f.py</u> failed with error 404 (File not Found). "
"Are your filename and path are correct?"
)
else:
expected = (
"Loading from file <u>./f.py</u> failed with error 404 (File not Found). "
"Are your filename and path are correct?"
)
inner_html = self.page.locator(".py-error").inner_html()
assert localErrorContent in inner_html or serverErrorContent in inner_html
assert "Failed to load resource" in self.console.error.lines[0]
assert "Caught an error in fetchPaths" in self.console.warning.lines[0]
with pytest.raises(JsErrors) as exc:
self.check_js_errors()
received_error_msg = str(exc.value)
assert (
localErrorContent in received_error_msg
or serverErrorContent in received_error_msg
)
assert expected in inner_html
assert expected in self.console.error.lines[-1]
def test_paths_from_packages(self):
self.writefile("utils/__init__.py", "")