JSO: make global objects available in WebWorker contexts (no hardcoded window)

This commit is contained in:
Bernd Busse 2023-07-31 20:16:14 +02:00 committed by Alexey Andreev
parent 6ac598b927
commit 7f333cc73e
3 changed files with 5 additions and 6 deletions

View File

@ -190,9 +190,9 @@ public abstract class Window implements JSObject, WindowEventTarget, StorageProv
@JSProperty
public abstract double getDevicePixelRatio();
@JSBody(params = "s", script = "return window.atob(s);")
@JSBody(params = "s", script = "return atob(s);")
public static native String atob(String s);
@JSBody(params = "s", script = "return window.btoa(s);")
@JSBody(params = "s", script = "return btoa(s);")
public static native String btoa(String s);
}

View File

@ -25,10 +25,10 @@ import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.typedarrays.Uint8ClampedArray;
public abstract class Crypto implements JSObject {
@JSBody(script = "return window.crypto != null;")
@JSBody(script = "return crypto != null;")
public static native boolean isSupported();
@JSBody(script = "return window.crypto;")
@JSBody(script = "return crypto;")
public static native Crypto current();
public abstract String randomUUID();

View File

@ -34,8 +34,7 @@ public abstract class IDBFactory implements JSObject {
return factory;
}
@JSBody(script = "return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || "
+ "window.msIndexedDB;")
@JSBody(script = "return indexedDB || mozIndexedDB || webkitIndexedDB || msIndexedDB;")
static native IDBFactory getInstanceImpl();
public abstract IDBOpenDBRequest open(String name, int version);