Limits and containment
A run that never ends is stopped; the sandbox has no network and cannot reach this page.
Framework decisions behind it: D5, D6, D50, D57.
Code in a playground runs in a sandboxed frame on an opaque origin, in a worker with no network. Nothing runs until the reader acts.
Try to escape
Press Run. Every attempt should say blocked.
// Each line tries to reach out of the sandbox.
const attempts = {
"network (fetch)": () => fetch("/"),
"network (WebSocket)": () =>
new Promise((resolve, reject) => {
const socket = new WebSocket("wss://example.com/");
socket.onopen = () => resolve(socket);
socket.onerror = () => reject(new Error("connection refused"));
}),
"the page's document": () => document.title,
"the page's cookies": () => document.cookie,
"the parent page": () => parent.location.href,
};
for (const [name, attempt] of Object.entries(attempts)) {
try {
await attempt();
console.log(name + ": reachable");
} catch (error) {
console.log(name + ": blocked (" + error.name + ")");
}
}
A run that never ends
This loop has no end. The playground sets run-timeout="2000", so the run is stopped after two seconds, the worker is replaced, and the page stays responsive.
while (true) {}
This site is hosted on GitHub Pages, which cannot send custom headers; About says what that changes.