From 0e37184ca8084c257948d466c066fdb875ee44f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 26 Feb 2020 11:49:38 +0100 Subject: [PATCH] add window.self read-only property (#4131) --- cli/js/globals_test.ts | 12 ++++++++++++ cli/js/lib.deno.window.d.ts | 2 ++ cli/js/runtime_main.ts | 1 + 3 files changed, 15 insertions(+) diff --git a/cli/js/globals_test.ts b/cli/js/globals_test.ts index d6bc87f5c6cbe5..70c5e4e374a04a 100644 --- a/cli/js/globals_test.ts +++ b/cli/js/globals_test.ts @@ -9,14 +9,26 @@ test(function windowExists(): void { assert(window != null); }); +test(function selfExists(): void { + assert(self != null); +}); + test(function windowWindowExists(): void { assert(window.window === window); }); +test(function windowSelfExists(): void { + assert(window.self === window); +}); + test(function globalThisEqualsWindow(): void { assert(globalThis === window); }); +test(function globalThisEqualsSelf(): void { + assert(globalThis === self); +}); + test(function DenoNamespaceExists(): void { assert(Deno != null); }); diff --git a/cli/js/lib.deno.window.d.ts b/cli/js/lib.deno.window.d.ts index 2c6228919268d5..737971d942641d 100644 --- a/cli/js/lib.deno.window.d.ts +++ b/cli/js/lib.deno.window.d.ts @@ -9,6 +9,7 @@ declare interface Window extends WindowOrWorkerGlobalScope { window: Window & WindowOrWorkerGlobalScope & typeof globalThis; + self: Window & WindowOrWorkerGlobalScope & typeof globalThis; onload: Function | undefined; onunload: Function | undefined; crypto: Crypto; @@ -16,6 +17,7 @@ declare interface Window extends WindowOrWorkerGlobalScope { } declare const window: Window & WindowOrWorkerGlobalScope & typeof globalThis; +declare const self: Window & WindowOrWorkerGlobalScope & typeof globalThis; declare const onload: Function | undefined; declare const onunload: Function | undefined; declare const crypto: Crypto; diff --git a/cli/js/runtime_main.ts b/cli/js/runtime_main.ts index b5517cbcb61054..96bda3cb0f0fdd 100644 --- a/cli/js/runtime_main.ts +++ b/cli/js/runtime_main.ts @@ -32,6 +32,7 @@ Deno[Deno.symbols.internal] = internalObject; export const mainRuntimeGlobalProperties = { window: readOnly(globalThis), + self: readOnly(globalThis), Deno: readOnly(Deno), crypto: readOnly(csprng),