Closed Bug 672690 Opened 14 years ago Closed 14 years ago

Expose XMLHttpRequest and FormData as constructors in JS modules

Categories

(Core :: XPConnect, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 439286

People

(Reporter: jdm, Unassigned)

Details

It would be convenient for me if these were exposed as real constructors. Currently I'm grabbing references to them from a DOM window, but that feels less than ideal.
For XHR there's a simple workaround as explained at https://developer.mozilla.org/En/Using_XMLHttpRequest#Using_XMLHttpRequest_from_JavaScript_modules_.2f_XPCOM.c2.a0components Being able to use just new XMLHttpRequest() instead of Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] .createInstance(Components.interfaces.nsIXMLHttpRequest) would be nice, but I don't think that it's a big problem. But for FormData I don't know of any workaround, so I would change the bug to deal just with this issue.
OS: Mac OS X → All
Well, I'm able to create both interfaces via createInstance. It's just not ideal.
And what's the code to create a FormData? So far I haven't been able to find any documentation about that. Thank you. But if you can create then with createInstance, why did you state that you are "grabbing references to them from a DOM window"?, that forces your code to get a reference to a window that you wouldn't need otherwise
After reading the original patch I've found the implementation, so this seems to work: var formData = Components.classes["@mozilla.org/files/formdata;1"] .createInstance(Components.interfaces.nsIDOMFormData); Now I just need to find how to do new File(path);
As of Firefox 8 you can just do "new File(path)" in a component.
(In reply to comment #5) > As of Firefox 8 you can just do "new File(path)" in a component. Thank you, that worked. Any chance of having some code (even calling some weird code like that .createInstance) that works in 6 or 7? (I'm really liking the fast release cycle and being able to use such new features and fixes without waiting years)
(In reply to comment #6) > (In reply to comment #5) > > As of Firefox 8 you can just do "new File(path)" in a component. > > Thank you, that worked. > Any chance of having some code (even calling some weird code like that > .createInstance) that works in 6 or 7? Probably not, precisely because of ... > (I'm really liking the fast release cycle and being able to use such new > features and fixes without waiting years) Indeed. It's awesome!
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.