mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-02 08:59:23 +08:00
web: drop window errors from scripts not of the page's origin (a browser's wallet or an extension), which could fail the boot
This commit is contained in:
@@ -159,6 +159,18 @@
|
||||
"<" + t.tagName.toLowerCase() + "> load error (404, network or MIME type)", t.tagName === "SCRIPT");
|
||||
return;
|
||||
}
|
||||
// Scripts a browser or an extension injects (Brave's wallet touching window.ethereum, say) throw here too:
|
||||
// drop an error that names no script of the page's origin (a blob: URL of it, or wasm), so it cannot fail the boot.
|
||||
if (location.origin !== "null") {
|
||||
let ours;
|
||||
try {
|
||||
const u = new URL(ev.filename);
|
||||
ours = u.origin === location.origin || u.protocol === "wasm:";
|
||||
} catch {
|
||||
ours = String(ev.error?.stack || "").includes(location.origin);
|
||||
}
|
||||
if (!ours) return;
|
||||
}
|
||||
KW.report("exception", ev.message || "Script error", ev.error?.stack || (ev.filename ? ev.filename + ":" + ev.lineno + ":" + ev.colno : ""), !KW.started);
|
||||
}, true);
|
||||
addEventListener("unhandledrejection", (ev) => {
|
||||
|
||||
Reference in New Issue
Block a user