Closed
Bug 1164188
Opened 9 years ago
Closed 6 years ago
Expose the XMLHttpRequest (XHR) constructor in system scopes by default
Categories
(Core :: DOM: Core & HTML, defect, P5)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
DUPLICATE
of bug 1489301
Tracking | Status | |
---|---|---|
firefox41 | --- | affected |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(3 files, 2 obsolete files)
43.25 KB,
patch
|
Details | Diff | Splinter Review | |
8.37 KB,
patch
|
Details | Diff | Splinter Review | |
10.93 KB,
patch
|
Details | Diff | Splinter Review |
It can already be imported, so there's no reason not to do it.
Assignee | ||
Comment 1•9 years ago
|
||
Hrm. So maybe we can't do this because of addons. :( There's "const XMLHttpRequest" all over addon code. :(
Mostly from "resources/api-utils/lib/self!.js" and "boostrap.js", which I think is addon SDK stuff, so _maybe_ wouldn't be an issue? But there are some other uses too, looks like. This is why we can't have nice things.
Once bug 589199 is fixed we can do this.
Depends on: 589199
Assignee | ||
Comment 2•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment 3•9 years ago
|
||
Bug 589199 seems to have landed
Assignee | ||
Comment 4•9 years ago
|
||
Yeah, need to test that the way that was actually fixed for addons will still work with the "const XMLHttpRequest" stuff... I'm not quite sure how to go about doing that, and this is pretty low-priority for me. If someone wants to do the testing and get the patch in, please feel free to steal.
Comment 5•9 years ago
|
||
All add-ons using "const XMLHttpRequest" should have been rewritten due to global lexical scope for let/const. If not, it is already broken.
Updated•6 years ago
|
Priority: -- → P5
Comment 7•6 years ago
|
||
Is this still something we want to do, bz? (I'm not sure if it squares with our efforts to minimize memory usage).
Flags: needinfo?(bzbarsky)
Assignee | ||
Comment 8•6 years ago
|
||
So first off [Exposed=System] adds a bit of data to the table used by ResolveSystemBinding. It doesn't really cause memory usage other than that if the global in question doesn't use the relevant binding.
Past that, [Exposed=System] exposes the API in three places:
* ContentFrameMessageManager globals
* ProcessGlobal globals
* BackstagePass globals
The first two are going to go away in bug 1480244. For BackstagePass, it looks like we create globals using it in:
1) ipc::XPCShellEnvironment::Init
2) mozJSComponentLoader::CreateLoaderGlobal
3) XRE_XPCShellMain
We don't really care about #1 and #3. CreateLoaderGlobal can be called from:
a) mozJSComponentLoader::GetSharedGlobal
b) mozJSComponentLoader::PrepareObjectForLocation
There's only one shared global. PrepareObjectForLocation uses the shared global unless ReuseGlobal(aURI) returns false. Since we set pref("jsloader.shareGlobal", true), we use the shared global for everything except "resource://gre/modules/commonjs/toolkit/loader.js", resource://gre/modules/jsdebugger.jsm, and resource://specialpowers/*.
In a release build I expect we don't have specialpowers bits. The "resource://gre/modules/commonjs/toolkit/loader.js" thing no longer exists. So apart from the shared global we'd only need to worry about exposing in jsdebugger.jsm...
I suspect we should in fact just expose this to System. Kris, any objections?
Flags: needinfo?(bzbarsky) → needinfo?(kmaglione+bmo)
Comment 9•6 years ago
|
||
Agreed, I can't think of any reason not to do this. If anything, it will probably save memory by preventing people from eagerly importing it before it's needed.
Flags: needinfo?(kmaglione+bmo)
Comment 10•6 years ago
|
||
That all sounds good to me. Is there a reason to not try landing the patch, then?
Assignee | ||
Comment 11•6 years ago
|
||
Try run of patch plus some cleanup is at https://treeherder.mozilla.org/#/jobs?repo=try&revision=cb8be8f421554bbe50aaad92116d25827ada3fe8
Once I make sure it's green I will post things for review.
Assignee | ||
Comment 12•6 years ago
|
||
OK, so the try run is very orange, because if I expose XHR to System, then the Window-only-exposed .responseXML getter is _not_ exposed to System and getting .responseXML from XHRs fails in system scopes.
And exposing that getter to System requires that its return type (Document) be exposed to System.
And that requires, by the same argument, that the return types of all properties of Document, and all consequential interfaces of all those types, and all the return types of those, etc, be exposed to System.
So we end up needing to expose a lot of things to System. I'll post a patch that does that, in case we want to.
Assignee | ||
Comment 13•6 years ago
|
||
Another option would be to just expose everything that's exposed in Window in system scopes....
Assignee | ||
Comment 14•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Attachment #8604914 -
Attachment is obsolete: true
Assignee | ||
Comment 15•6 years ago
|
||
xpcshell has this by default now.
Assignee | ||
Comment 16•6 years ago
|
||
The JSM global has this by default now.
Assignee | ||
Comment 17•6 years ago
|
||
The JSM global has this by default now.
Assignee | ||
Updated•6 years ago
|
Attachment #9001481 -
Attachment is obsolete: true
Assignee | ||
Comment 18•6 years ago
|
||
This got fixed in bug 1489301.
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•