Closed
Bug 1317422
(globalThis)
Opened 8 years ago
Closed 6 years ago
Implement "globalThis" proposal
Categories
(Core :: JavaScript: Standard Library, enhancement, P5)
Core
JavaScript: Standard Library
Tracking
()
RESOLVED
FIXED
mozilla65
People
(Reporter: anba, Assigned: evilpies)
References
(Blocks 2 open bugs, )
Details
(Keywords: dev-doc-complete)
Attachments
(3 files, 1 obsolete file)
7.45 KB,
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
5.96 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
47 bytes,
text/x-phabricator-request
|
Details | Review |
"global" [1] is currently a stage 3 proposal [2, 3].
test262 already tests for the new "global" property [4] and we're currently failing some tests because of this.
[1] https://github.com/tc39/proposal-global
[2] https://github.com/tc39/proposals
[3] https://github.com/tc39/ecma262/pull/702
[4] https://github.com/tc39/test262/pull/765
Comment 1•8 years ago
|
||
#jslang suckered me into it.
Attachment #8815143 -
Flags: review?(andrebargull)
Updated•8 years ago
|
Assignee: nobody → jwalden+bmo
Status: NEW → ASSIGNED
Reporter | ||
Comment 3•8 years ago
|
||
Comment on attachment 8815143 [details] [diff] [review]
Patch
Review of attachment 8815143 [details] [diff] [review]:
-----------------------------------------------------------------
Let's find out if this breaks any websites! :-D
::: js/src/tests/ecma_2017/Global/global-property-enumeration.js
@@ +28,5 @@
> +assertEq(desc.configurable, true);
> +assertEq(desc.writable, true);
> +assertEq(desc.value, this);
> +
> +global = 42;
The other test case already tests that `global = 42` works, should this one instead test with `this.global = 42`?
Attachment #8815143 -
Flags: review?(andrebargull) → review+
Comment 4•8 years ago
|
||
Patch works fine for shell, doesn't work for browser. Turns out I need a ToWindowProxyIfWindow in there. But even that's not enough, because in the browser embedding, nsGlobalWindow::SetNewDocument invokes Object class init (in the process of setting up the window's prototype chain) before it creates the WindowProxy wrapper and calls js::SetWindowProxy to store the wrapper in the WINDOW_PROXY slot in the Window.
The right fix to me seems to be to refactor things so the slot's filled early enough that Object class init doesn't have these oddities to deal with. But SetNewDocument looks an awful lot like Mos Eisley -- a wretched hive of scum and villainy -- and doesn't look particularly refactorable, nor does it seem like a good use of time to do so. (I want to refactor global object creation at *some* point, so that embeddings can basically declaratively specify what they want their global object to look like, including its prototype chain. So I'll probably get back to this eventually. Just, not now.)
With the Object init approach out, I stole the approach evilpie mentioned on IRC (aside: it's truly awful that there are multiple ways to define a new one-off global property), fixed the one moderately obvious bug in it, and am tryservering it now. Will post for a fresh review if it comes back okay.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=a7cf02615566f272bd0ad7a89c865262a2a2ce62
Comment 5•8 years ago
|
||
Pretty sure jandem dealt with the ToWindow* gunk at one point, so let's throw this at him this time around.
Attachment #8816662 -
Flags: review?(jdemooij)
Updated•8 years ago
|
Attachment #8815143 -
Attachment is obsolete: true
Comment 6•8 years ago
|
||
Comment on attachment 8816662 [details] [diff] [review]
Patch, v2
Review of attachment 8816662 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM.
Attachment #8816662 -
Flags: review?(jdemooij) → review+
Updated•8 years ago
|
Keywords: dev-doc-needed
Pushed by jwalden@mit.edu:
https://hg.mozilla.org/integration/mozilla-inbound/rev/d37fc752b0af
Implement a global 'global' property whose value is the global object. r=jandem
Comment 9•8 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Comment 10•8 years ago
|
||
Yay! When will this land in nightly and stable?
Comment 11•8 years ago
|
||
(In reply to ljharb from comment #10)
> Yay! When will this land in nightly and stable?
It will be in today's Nightly. Firefox 53 will be released April 18th, according to https://wiki.mozilla.org/RapidRelease/Calendar
Assignee | ||
Comment 12•8 years ago
|
||
Let's back this out. This is not web-compatible.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 13•8 years ago
|
||
Attachment #8823427 -
Flags: review?(jwalden+bmo)
Comment 14•8 years ago
|
||
Comment on attachment 8823427 [details] [diff] [review]
Backout
Review of attachment 8823427 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/jsapi.cpp
@@ +1076,5 @@
> // Object.prototype yet. Force it now.
> + if (!global->getOrCreateObjectPrototype(cx))
> + return false;
> +
> + return true;
Mind also landing a separate patch, rs=me, that undoes this undoing, and keeps |global| as a Handle?
Attachment #8823427 -
Flags: review?(jwalden+bmo) → review+
Comment 15•8 years ago
|
||
Is there a way we could still include `global` behind a flag in nightly, so that continued testing can be done as sites fix their issues?
Comment 16•8 years ago
|
||
Sure, we could add something to CompartmentOptions to frob it on, easily enough. Invoking the frob other than as an all-or-nothing approach, tho, seems difficult. I'm not sure exactly how useful such a thing is. We've used such frobs to feature-guard stuff in progress, like some Intl functionality, but that was only with the aim of having an opt-in in shell tests to enable it. And obviously, we can't expose such a thing to web content.
Comment 17•8 years ago
|
||
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/aa5f92e32f1d
Backout the global property propsal. r=Waldo
https://hg.mozilla.org/integration/mozilla-inbound/rev/89388a238c25
Keep nicer code in JS_ResolveStandardClass. rs=Waldo
Comment 18•8 years ago
|
||
How about enabling this just for 'strict' contexts, wouldn't it be more compatible ir current web content?
Comment 19•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/aa5f92e32f1d
https://hg.mozilla.org/mozilla-central/rev/89388a238c25
Status: REOPENED → RESOLVED
Closed: 8 years ago → 8 years ago
Resolution: --- → FIXED
Updated•8 years ago
|
Status: RESOLVED → REOPENED
status-firefox53:
fixed → ---
Resolution: FIXED → ---
Target Milestone: mozilla53 → ---
Updated•8 years ago
|
Status: REOPENED → ASSIGNED
![]() |
||
Comment 20•8 years ago
|
||
After implementing it in Safari Tech Preview 21
> Added support for the global property on the global object (r210052)
https://webkit.org/blog/7265/release-notes-for-safari-technology-preview-21/
It has been reverted for Web Compatibility reasons
See https://bugs.webkit.org/show_bug.cgi?id=166915
Ryosuke Niwa said
> We had to rollout this feature it broke Polymer tests.
https://bugs.webkit.org/show_bug.cgi?id=165171#c22
Updated•7 years ago
|
Priority: -- → P5
Blocks: es-proposals-stage-3
QA Contact: jorendorff
Assignee | ||
Comment 21•6 years ago
|
||
From Alexandre Folle de Menezes in bug 1496748
> The 'global' proposal was renamed to 'globalThis'. I believe this was
> already implemented with the old name, but disabled due to compatibility
> issues.
>
> Chrome 70 already has the renamed implementation.
Updated•6 years ago
|
QA Contact: jorendorff
Assignee | ||
Comment 23•6 years ago
|
||
Should be easy to implement this. I would volunteer to do it.
Assignee | ||
Comment 24•6 years ago
|
||
Oh the original patch was actually not quite correct: We would resolve "global" again after it was deleted. Thanks test262 for catching this!
Assignee | ||
Comment 25•6 years ago
|
||
Summary: Implement "global" proposal → Implement "globalThis" proposal
Comment 26•6 years ago
|
||
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/1e6a2dbfa104
Implement JavaScript globalThis proposal. r=jandem
Comment 27•6 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 8 years ago → 6 years ago
status-firefox65:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Updated•6 years ago
|
Alias: globalThis
status-firefox64:
--- → wontfix
Comment 28•6 years ago
|
||
Note to MDN writers:
I have added to note to the Fx65 rel notes to cover this:
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/65#JavaScript
It would be great to get this documented fairly promptly in the new year. The Trello card is here:
https://trello.com/c/aRcYBQqA/150-globalthis-fx-65
Awesomely enough, we already seem to have it in Chinese, added by a volunteer:
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/globalThis
Comment 29•6 years ago
|
||
We need to do the following tasks on MDN:
Add browser compat data:
- Add "globalThis" to https://github.com/mdn/browser-compat-data/blob/master/javascript/builtins/globals.json
Add reference docs:
- Create https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
- Can be modeled after e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined
- Should talk about globalthis, self, this, window.
- Examples could be global with web workers, global in modules, ...
- Mention "globalThis" on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects under "Value properties"
Add interactive example:
- The folder is https://github.com/mdn/interactive-examples/tree/master/live-examples/js-examples/globalprops
- Add a new globalThis example and embed it in the globalThis reference page.
Links from other docs
We should probably link to the globalThis page from these MDN pages:
Comment 30•6 years ago
|
||
The docs are put in place thanks to Helen Durrant, https://twitter.com/goodforenergy
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/65#JavaScript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
Reviews, comments, and tweaks to the MDN wiki pages are welcome (as always).
Keywords: dev-doc-needed → dev-doc-complete
Updated•6 years ago
|
Type: defect → enhancement
You need to log in
before you can comment on or make changes to this bug.
Description
•