Fix #1943 - Updated Polyscript with configURL (#1944)

This commit is contained in:
Andrea Giammarchi
2024-01-17 16:15:51 +01:00
committed by GitHub
parent 1efd73af8f
commit 7ad7f0abfb
8 changed files with 232 additions and 181 deletions

View File

@@ -6,6 +6,12 @@
<title>PyScript Next Plugin</title>
<link rel="stylesheet" href="../dist/core.css">
<script type="module" src="../dist/core.js"></script>
<py-config src="bad.toml" type="toml"></py-config>
<mpy-config src="config-url/config.json"></mpy-config>
<script type="mpy">
from runtime import test
</script>
<script type="mpy" worker>
from runtime import test
</script>
</head>
</html>

View File

@@ -0,0 +1,7 @@
{
"files":{
"{FROM}": "./src",
"{TO}": "./runtime",
"{FROM}/test.py": "{TO}/test.py"
}
}

View File

@@ -0,0 +1,8 @@
from pyscript import RUNNING_IN_WORKER, document
classList = document.documentElement.classList
if RUNNING_IN_WORKER:
classList.add("worker")
else:
classList.add("main")

View File

@@ -51,3 +51,14 @@ test('MicroPython + Pyodide js_modules', async ({ page }) => {
await expect(logs[3]).toBe(logs[4]);
await expect(logs[4]).toBe(logs[5]);
});
test('MicroPython + configURL', async ({ page }) => {
const logs = [];
page.on('console', msg => {
const text = msg.text();
if (!text.startsWith('['))
logs.push(text);
});
await page.goto('http://localhost:8080/test/config-url.html');
await page.waitForSelector('html.main.worker');
});