Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
// A file: document loads other local files only under the root the browser granted it, which is the test tree here.
function load(url) {
return new Promise(resolve => {
const script = document.createElement("script");
script.src = url;
script.onload = () => resolve("loaded");
script.onerror = () => resolve("refused");
document.head.appendChild(script);
});
}
promiseTest(async () => {
println(`a regular file: ${await load(new URL("file-script-canary.js", window.location.href).href)}`);
for (const path of [
"/etc/hosts",
"/proc/self/maps",
"/proc/self/environ",
"/proc/self/fd/0",
"/sys/kernel/mm/transparent_hugepage/enabled",
"/dev/fd/0",
"/dev/stdin",
"/dev/null",
])
println(`${path}: ${await load(`file://${path}`)}`);
});
</script>