Files
scriptc/tests/corpus/global-stored-probes.js
Chris Tate f668fc4bfd Support native runtime values used by OpenTUI
- Add shared ArrayBuffer storage and native Unicode grapheme segmentation.
- Preserve builtin modules, globals, and byte views across JavaScript bindings.
- Compile package initialization expressions and optional native callables.
2026-09-28 19:01:50 -05:00

31 lines
1.2 KiB
JavaScript

before();
try { probe(); } catch (error) { console.log(error.name, error.message); }
var scope = globalThis;
console.log(typeof scope, scope === globalThis, scope === global);
console.log(scope.globalThis === scope, scope.global === scope);
console.log(scope.NaN !== scope.NaN, scope.Infinity === Infinity, scope.undefined === undefined);
console.log(probe(), scope.Worker, scope.close);
function probe() { return typeof scope.postMessage; }
function before() { console.log(typeof scope, scope?.Bun); }
function local() {
beforeLocal();
var host = globalThis;
const copy = host;
console.log(copy === host, copy.Bun, host.Deno);
host = { postMessage: () => "local" };
console.log(host.postMessage(), copy.postMessage);
function beforeLocal() { console.log(typeof host, host?.Bun); }
}
local();
scope = { postMessage: () => "replaced" };
console.log(probe(), scope.postMessage());
function shadowed(globalThis) {
var host = globalThis;
return host.Bun;
}
console.log(shadowed({ Bun: "shadow" }));
try { readLexical(); } catch (error) { console.log(error.name); }
let lexical = globalThis;
console.log(readLexical());
function readLexical() { return typeof lexical.Bun; }