v8/test/mjsunit/harmony/global.js
Mathias Bynens 620410a1f0 Implement global proposal
The proposal is currently at Stage 3 of the TC39 process.
Repository: https://github.com/tc39/proposal-global

Bug: v8:5537
Change-Id: I36c39fdab049497f50685c6672655b67ec4d8ce9
Reviewed-on: https://chromium-review.googlesource.com/1174113
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55159}
2018-08-16 11:07:21 +00:00

29 lines
851 B
JavaScript

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-global
assertEquals(globalThis, this);
assertEquals(this.globalThis, this);
assertEquals(globalThis.globalThis, this);
assertEquals(globalThis.globalThis.globalThis, this);
assertEquals(globalThis.globalThis.globalThis.globalThis, this);
{
const realm = Realm.create();
assertEquals(Realm.global(realm), Realm.eval(realm, 'globalThis'));
assertTrue(Realm.global(realm) !== globalThis);
}
{
const descriptor = Object.getOwnPropertyDescriptor(
this,
'globalThis'
);
assertEquals(descriptor.value, this);
assertEquals(descriptor.writable, true);
assertEquals(descriptor.enumerable, false);
assertEquals(descriptor.configurable, true);
}