Skip to content

Commit

Permalink
add window.self read-only property (#4131)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored Feb 26, 2020
1 parent 5946808 commit 0e37184
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cli/js/globals_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 2 additions & 0 deletions cli/js/lib.deno.window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

declare interface Window extends WindowOrWorkerGlobalScope {
window: Window & WindowOrWorkerGlobalScope & typeof globalThis;
self: Window & WindowOrWorkerGlobalScope & typeof globalThis;
onload: Function | undefined;
onunload: Function | undefined;
crypto: Crypto;
Deno: typeof Deno;
}

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;
Expand Down
1 change: 1 addition & 0 deletions cli/js/runtime_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Deno[Deno.symbols.internal] = internalObject;

export const mainRuntimeGlobalProperties = {
window: readOnly(globalThis),
self: readOnly(globalThis),
Deno: readOnly(Deno),

crypto: readOnly(csprng),
Expand Down

0 comments on commit 0e37184

Please sign in to comment.