LibJS: Use the real globalThis value

Previously it used `realm.[[GlobalObject]]` instead of
`realm.[[GlobalEnv]].[[GlobalThisValue]]`.

In LibWeb, that corresponds to Window and WindowProxy respectively.
This commit is contained in:
Luke Wilde
2026-04-23 19:19:01 +01:00
committed by Luke Wilde
parent 36e6323d1f
commit 3d3b02b9c0
Notes: github-actions[bot] 2026-04-23 19:44:08 +00:00
3 changed files with 32 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<iframe id="ifr" srcdoc=""></iframe>
<script>
test(() => {
println(`globalThis === window: ${globalThis === window}`);
println(`globalThis === self: ${globalThis === self}`);
println(`globalThis === frames: ${globalThis === frames}`);
println(`globalThis === this: ${globalThis === this}`);
const iframeWindow = ifr.contentWindow;
println(`iframe contentWindow === iframe globalThis: ${iframeWindow === iframeWindow.globalThis}`);
println(`iframe globalThis === iframe self: ${iframeWindow.globalThis === iframeWindow.self}`);
iframeWindow.eval("window.__check = globalThis === window;");
println(`iframe realm globalThis === window: ${iframeWindow.__check}`);
println(`globalThis !== iframe globalThis: ${globalThis !== iframeWindow.globalThis}`);
println(`Object.getPrototypeOf(globalThis) === Object.getPrototypeOf(window): ${Object.getPrototypeOf(globalThis) === Object.getPrototypeOf(window)}`);
});
</script>