Last Comment Bug 355151 - XML-RPC fails with "XMLHttpRequest is not defined" due to assuming namespace pollution
: XML-RPC fails with "XMLHttpRequest is not defined" due to assuming namespace ...
Status: RESOLVED FIXED
: fixed1.8.1.1
Product: Core
Classification: Components
Component: XML (show other bugs)
: Trunk
: All All
: -- major with 2 votes (vote)
: ---
Assigned To: James Ross
: Ashish Bhatt
Mentors:
: 358529 361618 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-02 13:07 PDT by Krzysztof Sobolewski
Modified: 2006-11-28 10:24 PST (History)
12 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
chrome/content/ServerStub.js (1.21 KB, application/x-javascript)
2006-10-02 13:11 PDT, Krzysztof Sobolewski
no flags Details
chrome/content/test.js (369 bytes, application/x-javascript)
2006-10-02 13:12 PDT, Krzysztof Sobolewski
no flags Details
chrome/content/test.xul (373 bytes, application/vnd.mozilla.xul+xml)
2006-10-02 13:12 PDT, Krzysztof Sobolewski
no flags Details
chrome.manifest (107 bytes, text/plain)
2006-10-02 13:13 PDT, Krzysztof Sobolewski
no flags Details
install.rdf (658 bytes, application/xml)
2006-10-02 13:14 PDT, Krzysztof Sobolewski
no flags Details
Use code from original page in bug 197087 (982 bytes, patch)
2006-10-23 03:58 PDT, James Ross
samuel: review+
cbiesinger: superreview+
dveditz: approval1.8.1.1+
Details | Diff | Splinter Review

Description Krzysztof Sobolewski 2006-10-02 13:07:13 PDT
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...
Comment 1 Dave Townsend [:mossop] 2006-10-02 13:09:32 PDT
It works fine for me. Can you attach a testcase?
Comment 2 Krzysztof Sobolewski 2006-10-02 13:11:41 PDT
Created attachment 240968 [details]
chrome/content/ServerStub.js

Part of the test extesion that fails for me.
Comment 3 Krzysztof Sobolewski 2006-10-02 13:12:17 PDT
Created attachment 240969 [details]
chrome/content/test.js

Part of the test extesion that fails for me.
Comment 4 Krzysztof Sobolewski 2006-10-02 13:12:57 PDT
Created attachment 240971 [details]
chrome/content/test.xul

Part of the test extension that fails for me.
Comment 5 Krzysztof Sobolewski 2006-10-02 13:13:38 PDT
Created attachment 240972 [details]
chrome.manifest

Part of the test extension that fails for me.
Comment 6 Krzysztof Sobolewski 2006-10-02 13:14:07 PDT
Created attachment 240973 [details]
install.rdf

Part of the test extension that fails for me.
Comment 7 Krzysztof Sobolewski 2006-10-02 13:16:10 PDT
(In reply to comment #1)
> It works fine for me. Can you attach a testcase?

Wow, you're quick :)

Testcase attached.
Comment 8 Krzysztof Sobolewski 2006-10-08 06:51:00 PDT
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...]
Comment 9 Christian Stocker 2006-10-16 07:03:20 PDT
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 :))
Comment 10 Krzysztof Sobolewski 2006-10-16 11:54:10 PDT
(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!
Comment 11 Christian Stocker 2006-10-19 00:42:03 PDT
noone looking at this one?

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

TIA
Comment 12 Samuel Sieb 2006-10-20 19:52:28 PDT
We don't need that workaround.  If |new XMLHttpRequest()| doesn't work, then it's a Firefox bug.
Comment 13 Christian Stocker 2006-10-21 00:52:09 PDT
(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 :)
Comment 14 Christian Stocker 2006-10-22 21:37:57 PDT
(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();

Comment 15 timeless 2006-10-23 03:18:11 PDT
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.
Comment 16 James Ross 2006-10-23 03:52:00 PDT
Yoink.
Comment 17 James Ross 2006-10-23 03:58:18 PDT
Created attachment 243174 [details] [diff] [review]
Use code from original page in bug 197087
Comment 18 James Ross 2006-10-23 03:59:33 PDT
That patch fixes the problem in my Firefox trunk/Windows.
Comment 19 James Ross 2006-10-24 05:38:40 PDT
Uh, thanks for that Bugzilla.
Comment 20 James Ross 2006-10-24 09:03:31 PDT
Checked in --> FIXED.

This is definitely needed on the MOZILLA_1_8_BRANCH.
Comment 21 Dave Townsend [:mossop] 2006-10-28 12:06:19 PDT
*** Bug 358529 has been marked as a duplicate of this bug. ***
Comment 22 James Ross 2006-10-28 12:18:24 PDT
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.
Comment 23 Daniel Veditz [:dveditz] 2006-11-09 10:36:53 PST
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
Comment 24 maisel 2006-11-13 01:03:47 PST
(In reply to comment #23)
Is there a roadmap when / in which Firefox version the fix will be released?
Comment 25 James Ross 2006-11-20 16:11:04 PST
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.
Comment 26 :Gavin Sharp [email: gavin@gavinsharp.com] 2006-11-22 20:43:03 PST
*** Bug 361618 has been marked as a duplicate of this bug. ***
Comment 27 Doug Turner (:dougt) 2006-11-23 09:31:58 PST
dan, i would love to have this for some of the work I am doing for ff2.x
Comment 28 Mike Shaver (:shaver -- probably not reading bugmail closely) 2006-11-27 08:37:03 PST
Yeah, I'd like to see this fix in 2.0.0.1 as well.
Comment 29 Doug Turner (:dougt) 2006-11-27 09:03:17 PST
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).   
Comment 30 James Ross 2006-11-27 09:49:21 PST
Until I'm back on Friday afternoon, Gijs Kruitbosch (Hannibal on IRC) is in charge of landing the patch, if needed.
Comment 31 Samuel Sieb 2006-11-27 14:36:55 PST
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 32 Daniel Veditz [:dveditz] 2006-11-28 01:02:42 PST
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.
Comment 33 :Gijs Kruitbosch 2006-11-28 10:24:33 PST
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

Note You need to log in before you can comment on or make changes to this bug.