Files
Netcatty/electron/plugins/fixtures/browser-runtime-plugin/index.js
T
ryan-wong-coder 7a47187e37 feat(plugins): add isolated plugin host runtime (#2303)
* feat(plugins): add isolated plugin host runtime

* test(plugins): build runtime dependencies before tests

* fix(plugins): harden runtime lifecycle and recovery

* fix(plugins): harden runtime extension boundaries

* fix(plugins): enforce runtime integrity boundaries

* fix(plugins): await utility process exit

* fix(plugins): harden utility process containment

* fix(plugins): close runtime recovery gaps

* fix(plugins): harden runtime lifecycle boundaries
2026-07-19 08:22:17 +08:00

32 lines
926 B
JavaScript

import { definePlugin } from "@netcatty/plugin-sdk";
export default definePlugin({
async activate(context) {
for (const capability of [
"fetch",
"RTCPeerConnection",
"WebSocket",
"WebTransport",
"Worker",
]) {
if (globalThis[capability] !== undefined) {
throw new Error(`Direct browser capability remains exposed: ${capability}`);
}
}
const iframe = document.createElement("iframe");
document.body.append(iframe);
let childNetworkBlocked = false;
try {
await iframe.contentWindow.fetch("https://netcatty-plugin-smoke.invalid/");
} catch {
childNetworkBlocked = true;
} finally {
iframe.remove();
}
if (!childNetworkBlocked) {
throw new Error("Child browsing context bypassed the offline plugin session");
}
await context.storage.set("smoke.activation", { kind: "browser", ready: true });
},
});