diff --git a/jso/apis/src/main/java/org/teavm/jso/browser/Navigator.java b/jso/apis/src/main/java/org/teavm/jso/browser/Navigator.java index 854505c82..e9bda2384 100644 --- a/jso/apis/src/main/java/org/teavm/jso/browser/Navigator.java +++ b/jso/apis/src/main/java/org/teavm/jso/browser/Navigator.java @@ -21,6 +21,6 @@ public final class Navigator { private Navigator() { } - @JSBody(script = "return (window || self).navigator.onLine;") + @JSBody(script = "return navigator.onLine;") public static native boolean isOnline(); } diff --git a/jso/apis/src/main/java/org/teavm/jso/browser/Performance.java b/jso/apis/src/main/java/org/teavm/jso/browser/Performance.java index 37c2b7009..a67c5c10e 100644 --- a/jso/apis/src/main/java/org/teavm/jso/browser/Performance.java +++ b/jso/apis/src/main/java/org/teavm/jso/browser/Performance.java @@ -22,9 +22,9 @@ public final class Performance implements JSObject { private Performance() { } - @JSBody(script = "return (window || self).performance.now();") + @JSBody(script = "return performance.now();") public static native double now(); - @JSBody(script = "return typeof((window || self).performance) !== 'undefined';") + @JSBody(script = "return typeof(performance) !== 'undefined';") public static native boolean isSupported(); } diff --git a/jso/apis/src/main/java/org/teavm/jso/browser/Window.java b/jso/apis/src/main/java/org/teavm/jso/browser/Window.java index a2a370412..0f00d8f5a 100644 --- a/jso/apis/src/main/java/org/teavm/jso/browser/Window.java +++ b/jso/apis/src/main/java/org/teavm/jso/browser/Window.java @@ -25,6 +25,8 @@ import org.teavm.jso.dom.html.HTMLElement; import org.teavm.jso.dom.html.HTMLIFrameElement; public abstract class Window implements JSObject, WindowEventTarget, StorageProvider, JSArrayReader { + private static Window cachedInstance; + private Window() { } @@ -159,9 +161,12 @@ public abstract class Window implements JSObject, WindowEventTarget, StorageProv postMessage(message, targetOrigin, JSArray.of(transfer)); } - @JSBody(script = "return window || self;") + @JSBody(script = "return window;") public static native Window current(); + @JSBody(script = "return self;") + public static native Window worker(); + @JSBody(params = "uri", script = "return encodeURI(uri);") public static native String encodeURI(String uri);