Closed Bug 355151 Opened 13 years ago Closed 13 years ago

XML-RPC fails with "XMLHttpRequest is not defined" due to assuming namespace pollution

Categories

(Core :: XML, defect, major)

defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: jezuch, Assigned: bugzilla-mozilla-20000923)

References

Details

(Keywords: fixed1.8.1.1)

Attachments

(6 files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.8.1) Gecko/20060918 Firefox/2.0
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.8.1) Gecko/20060918 Firefox/2.0

I'm trying to write an extension that uses supposedly built-in support for xml-rpc in Firefox, but it stopped working somewhere along the way to 2.0. I first tried in 2.0a, then 2.0RC1 and in both versions it stops my script with an error in the error console:

Error: XMLHttpRequest is not defined
Source file: file:///home/jezuch/incoming/firefox/components/nsXmlRpcClient.js
Line: 167

Error: uncaught exception: [Exception... "'[JavaScript Error: "XMLHttpRequest is not defined" {file: "file:///home/jezuch/incoming/firefox/components/nsXmlRpcClient.js" line: 167}]' when calling method: [nsIXmlRpcClient::asyncCall]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://urlman/content/ServerStub.js :: anonymous :: line 36"  data: yes]

For the record: it works _almost_ fine in 1.5 (the only problem is error handling code - one reference to unknown variable, but that ought to be another bug report and is probably obsolete anyway)

Reproducible: Always

Steps to Reproduce:
1. Create an extension that calls xml-rpc
2. Launch a remote call
3. Observe nothing happening [except error messages in error console, of course]
4. Maybe I'm doing something stupid? I'm new to extensions :)
Actual Results:  
The call should succeed or return error/fault.

Expected Results:  
The call fails silently, corrupts the xml-rpc client object.

This report is from a Firefox instance "installed" in my home folder in /home/jezuch/incoming, so it is obvious that it's plan vanilla Firefox :)

I think there might be a workaround, but I'd have to close Firefox and lose this report to see if it works...
It works fine for me. Can you attach a testcase?
Part of the test extesion that fails for me.
Attached file chrome/content/test.js
Part of the test extesion that fails for me.
Part of the test extension that fails for me.
Attached file chrome.manifest
Part of the test extension that fails for me.
Attached file install.rdf
Part of the test extension that fails for me.
(In reply to comment #1)
> It works fine for me. Can you attach a testcase?

Wow, you're quick :)

Testcase attached.
Still doesn't work with RC2 (of course).

Am I doing something wrong in my testcase?

This is rather important to me as I'm writing this extension for my diplomma and I'd like it to work ;) Still have some time to find another way that works, though... [if you say it works for you...]
I can reproduce the bug, but also have a fix :)

in nsXmlRpcClient.js line 169

change

this.xmlhttp = new XMLHttpRequest() 

to

this.xmlhttp =  Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();

and it works again.

(sorry for not delivering a proper patch, but I don't have the original sources from CVS currently and it's just a oneliner :))
(In reply to comment #9)
> I can reproduce the bug, but also have a fix :)
> 
> in nsXmlRpcClient.js line 169
> 
> change
> 
> this.xmlhttp = new XMLHttpRequest() 
> 
> to
> 
> this.xmlhttp = 
> Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
> 
> and it works again.

Perfect, it works indeed :)
I hope it makes into final 2.0...
Thanks!
noone looking at this one?

It's an easy fix and a quite obvious one :)

TIA
We don't need that workaround.  If |new XMLHttpRequest()| doesn't work, then it's a Firefox bug.
(In reply to comment #12)
> We don't need that workaround.  If |new XMLHttpRequest()| doesn't work, then
> it's a Firefox bug.


Ok, thanks for that answer, but who should a bug then? Or to which component should this bug be reassigned? I don't know enough of the Firefox developer internals to answer these questions by myself :)

Because it's the
"Nobody's working on this, feel free to take it <nobody@mozilla.org>"
part, which scares me a little :)
(In reply to comment #12)
> We don't need that workaround.  If |new XMLHttpRequest()| doesn't work, then
> it's a Firefox bug.
> 

Further looking into the problem, I'm wondering, why all the other modules in that directory are using 

 Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Components.interfaces.nsIXMLHttpRequest);

instead of

new XMLHttpRequest();

samuel@sieb.net: no no no.

We only pollute DOM global namespace with this nonsense.

Anyone writing an xpcom component using js is expected to ask for things specifically, otherwise if someone randomly pollutes the DOM namespace with something that overlaps a function that some js component wanted to write would cause unhappy results.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Yoink.
Severity: normal → major
Status: RESOLVED → UNCONFIRMED
Component: Extension Compatibility → XML
OS: Linux → All
Product: Firefox → Core
Resolution: INVALID → ---
Version: unspecified → Trunk
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → silver
Status: NEW → ASSIGNED
Attachment #243174 - Flags: review?(samuel)
That patch fixes the problem in my Firefox trunk/Windows.
Hardware: PC → All
Summary: XML-RPC: XmlHttpRequest is not defined → XML-RPC: XMLHttpRequest is not defined
Status: ASSIGNED → RESOLVED
Closed: 13 years ago13 years ago
QA Contact: extension.compatibility → ashshbhatt
Resolution: --- → FIXED
Uh, thanks for that Bugzilla.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → ASSIGNED
Attachment #243174 - Flags: review?(samuel) → review+
Checked in --> FIXED.

This is definitely needed on the MOZILLA_1_8_BRANCH.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → FIXED
*** Bug 358529 has been marked as a duplicate of this bug. ***
Comment on attachment 243174 [details] [diff] [review]
Use code from original page in bug 197087

Requesting approval for MOZILLA_1_8_BRANCH. This patch fixes XML RPC so that it works. :)

Risk is minimal, given it doesn't work without the patch.
Attachment #243174 - Flags: approval1.8.1?
Summary: XML-RPC: XMLHttpRequest is not defined → XML-RPC fails with "XMLHttpRequest is not defined" due to assuming namespace pollution
Comment on attachment 243174 [details] [diff] [review]
Use code from original page in bug 197087

moving 1.8.1 requests to 1.8.1.1 since 1.8.1 is out
Attachment #243174 - Flags: approval1.8.1? → approval1.8.1.1?
(In reply to comment #23)
Is there a roadmap when / in which Firefox version the fix will be released?
The fix is in trunk, which will become Firefox 3 some time next year. If/when the patch gets approval for the branch, it will then be in the next Firefox 2 release (I can't find anything that remotely explains what version this will be, mind, but I think it would be 2.0.1). The fact it has not had any indication of approval or denial in almost a month sucks.
*** Bug 361618 has been marked as a duplicate of this bug. ***
dan, i would love to have this for some of the work I am doing for ff2.x
Yeah, I'd like to see this fix in 2.0.0.1 as well.
any workarounds for older versions?  That is, i want to write a component that uses the xmlrpc client code and have it work in 2.0, or 1.5.x.  I was thinking about just shipping my own version (renamed, etc).   
Until I'm back on Friday afternoon, Gijs Kruitbosch (Hannibal on IRC) is in charge of landing the patch, if needed.
Doug, this change will work on all those versions.  As mentioned in the patch comment by James, this was how I originally did it, but was told the other method would work and would be simpler.
Comment on attachment 243174 [details] [diff] [review]
Use code from original page in bug 197087

approved for 1.8 branch, a=dveditz

Sorry this took so long to get to, but it wasn't nominated as a blocker, a security bug, topcrash or a regression so it's been bubbling along near the bottom of the huge pile of approval requests.
Attachment #243174 - Flags: approval1.8.1.1? → approval1.8.1.1+
Checked in on 1.8 branch.

Checking in mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js;
/cvsroot/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js,v  <--  nsXmlRpcClient.js
new revision: 1.34.28.3; previous revision: 1.34.28.2
done
Keywords: fixed1.8.1.1
You need to log in before you can comment on or make changes to this bug.