Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
promiseTest(async () => {
println(`public prototype unchanged: ${Object.getPrototypeOf(window) === Window.prototype}`);
window.windowProxyCacheProbe = "initial";
function readProbe() {
return window.windowProxyCacheProbe;
}
println(`initial value: ${readProbe()}`);
println(`cached initial value: ${readProbe()}`);
window.windowProxyCacheProbe = "changed";
println(`changed value: ${readProbe()}`);
Object.defineProperty(window, "windowProxyCacheProbe", {
configurable: true,
get() {
return this === window ? "getter with proxy receiver" : "wrong receiver";
},
});
println(`accessor value: ${readProbe()}`);
delete window.windowProxyCacheProbe;
window.windowProxyCacheProbe = "re-added";
println(`re-added value: ${readProbe()}`);
const iframe = document.createElement("iframe");
const firstLoad = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
iframe.srcdoc = `
<script>
window.windowProxyCacheProbe = "first document";
window.readSelfProbe = () => window.windowProxyCacheProbe;
<\/script>`;
document.body.appendChild(iframe);
await firstLoad;
const readStaleProbe = iframe.contentWindow.readSelfProbe;
println(`first document value: ${readStaleProbe()}`);
println(`cached first document value: ${readStaleProbe()}`);
const secondLoad = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
iframe.srcdoc = `
<script>
window.windowProxyCacheProbe = "second document";
<\/script>`;
await secondLoad;
internals.gc();
println(`stale function sees new value: ${readStaleProbe()}`);
});
</script>