Commit 9e5fe6ba authored by John Leidegren's avatar John Leidegren Committed by Brad Fitzpatrick

misc/wasm: use "self" instead of "window" in web worker contexts

There is no "window" global in a web worker context. Use "self" instead.

Fixes #26192

Change-Id: I6c6f3db6c3d3d9ca00a473f8c18b849bc07a0017
Reviewed-on: https://go-review.googlesource.com/122055
Run-TryBot: Richard Musiol <neelance@gmail.com>
Reviewed-by: 's avatarRichard Musiol <neelance@gmail.com>
parent 7145f1c7
......@@ -27,7 +27,13 @@
global.TextEncoder = util.TextEncoder;
global.TextDecoder = util.TextDecoder;
} else {
window.global = window;
if (typeof window !== "undefined") {
window.global = window;
} else if (typeof self !== "undefined") {
self.global = self;
} else {
throw new Error("cannot export Go (neither window nor self is defined)");
}
let outputBuf = "";
global.fs = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment