Intent to Ship: globalThis

211 views
Skip to first unread message

Mathias Bynens

unread,
Aug 30, 2018, 4:24:05 AM8/30/18
to blink-dev, v8-users

Contact emails

mat...@chromium.org


Spec

https://tc39.github.io/proposal-global/


Summary

A Stage 3 proposal introduces globalThis, enabling a universal mechanism to access the global object even in strict functions or modules, regardless of the platform.


Motivation

It is difficult to write portable ECMAScript code which accesses the global object. On the web, it is accessible as window or self or this or frames; on Node.js, it is global or this; among those, only this is available in a shell like V8's d8. In a standalone function call in sloppy mode, this works too, but it's undefined in modules or in strict mode within a function. In such contexts, the global object can still be accessed using Function('return this')(), but that form is incompatible with some CSP settings, such as within Chrome Apps.


Interoperability and compatibility risk

An earlier version of this proposal had a different name: global. Sadly, this name was found to be not Web-compatible when Firefox shipped it. After collaborating with other browsers vendors and looking at data on real-world use of JavaScript identifiers on the web, we believe the new name to be Web-compatible.


Is this feature fully tested?

Yes. In addition to V8's own tests (v8/test/mjsunit/harmony/global*.js), Test262 includes tests for this feature.


Tracking bug

https://bugs.chromium.org/p/v8/issues/detail?id=5537


Link to entry on the Chrome Platform Status dashboard

https://www.chromestatus.com/feature/6571514765770752


Requesting approval to ship?

Yes. Note that since this is a V8/JS feature, this post is just an FYI to blink-dev — no signoff from Blink API owners is required.


Adam Klein

unread,
Aug 30, 2018, 11:23:53 AM8/30/18
to v8-users, blink-dev
This LGTM, based on the stage at TC39.

It'd be nice if we knew more about other browser plans, given the history here. Do you know if Firefox has plans to try again with this name anytime soon?

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sathya Gunasekaran

unread,
Aug 30, 2018, 11:50:55 AM8/30/18
to v8-users, blink-dev
LGTM

Yuki Shiino

unread,
Aug 31, 2018, 9:12:07 AM8/31/18
to blink-dev, v8-u...@googlegroups.com, Domenic Denicola
IIUC, the proposed |globalThis| is a writable and configurable property, right?  It's easy to change(or fake) it.

Is there any chance to make it a readonly and non-configurable property?  Then, it's guaranteed to be the real global object.

+cc: domenic@, what do you think of this, especially from PoV of LAPI?

Cheers,
Yuki Shiino


2018年8月31日金曜日 0時50分55秒 UTC+9 Sathya Gunasekaran:
LGTM

To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscribe@googlegroups.com.

Domenic Denicola

unread,
Sep 6, 2018, 4:38:03 PM9/6/18
to Yuki Shiino, blink-dev, v8-u...@googlegroups.com
From: Yuki Shiino <yukis...@chromium.org>

> +cc: domenic@, what do you think of this, especially from PoV of LAPI?

This won't be useful for LAPIs, but that's OK. We need a bigger solution for the general problem of getting un-tamperable original references, and the global object is just one of many objects we'll need that for. There's no need to tie together those concerns with the globalThis proposal.

Yuki Shiino

unread,
Sep 6, 2018, 10:43:29 PM9/6/18
to Domenic Denicola, Yuki Shiino, blink-dev, v8-u...@googlegroups.com
I see.  If Domenic is okay, I'm okay, too.

LGTM.


2018年9月7日(金) 5:38 Domenic Denicola <d...@domenic.me>:
Reply all
Reply to author
Forward
0 new messages