diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js index e6c8921091ec12..8e64f13c35fddb 100644 --- a/misc/wasm/wasm_exec.js +++ b/misc/wasm/wasm_exec.js @@ -95,7 +95,7 @@ globalThis.Go = class { constructor() { this.argv = ["js"]; - this.env = {}; + this.scope = globalThis; this.exit = (code) => { if (code !== 0) { console.warn("exit code:", code); @@ -129,6 +129,7 @@ } const id = this.mem.getUint32(addr, true); + console.log("load value at addr", addr, id, this._values[id] == globalThis); return this._values[id]; } diff --git a/src/syscall/js/js.go b/src/syscall/js/js.go index 2f4f5adda02738..5cccc73a82417c 100644 --- a/src/syscall/js/js.go +++ b/src/syscall/js/js.go @@ -134,6 +134,12 @@ func Global() Value { return valueGlobal } +// Scope returns the JavaScript object attached to the Go class. +// If nothing has been explicitely set, this is usually "window", or "global". +func Scope() Value { + return jsGo.Get("scope") +} + // ValueOf returns x as a JavaScript value: // // | Go | JavaScript |