Last Comment Bug 778002 - Identity should createInstance XHR, not getService it
: Identity should createInstance XHR, not getService it
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Identity (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla17
Assigned To: Nobody; OK to take it and work on it
:
: Fernando Jiménez Moreno [:ferjm]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-26 17:32 PDT by Kyle Huey [:khuey] (Exited; not receiving bugmail, email if necessary)
Modified: 2012-07-31 06:12 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Use createInstance to get a new, not singleton, XHR instance on each invocation (1.06 KB, patch)
2012-07-27 10:56 PDT, Jed Parsons (use needinfo, please) [:jedp, :jparsons]
khuey: review+
Details | Diff | Splinter Review

Description Kyle Huey [:khuey] (Exited; not receiving bugmail, email if necessary) 2012-07-26 17:32:41 PDT
http://mxr.mozilla.org/mozilla-central/source/toolkit/identity/Identity.jsm#257

256     // this appears to be a more successful way to get at xmlhttprequest (which supposedly will close with a window
257     let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
258                 .getService(Ci.nsIXMLHttpRequest);

This is bad because you'll get the same XHR everytime.  If some other code (say an addon) does the same thing you'll cross the streams, and you could start getting load events fired for a totally different request.
Comment 1 Jed Parsons (use needinfo, please) [:jedp, :jparsons] 2012-07-26 17:58:29 PDT
And that would mean total protonic reversal.

Wow - thanks for catching this.  I had no idea getService returned a singleton.  But now I've found this: https://developer.mozilla.org/en/Components.classes and will update the code accordingly.

Thanks again, j.
Comment 2 Jed Parsons (use needinfo, please) [:jedp, :jparsons] 2012-07-27 10:56:47 PDT
Created attachment 646632 [details] [diff] [review]
Use createInstance to get a new, not singleton, XHR instance on each invocation

Hi, Kyle,

Is this correct?

Thanks,
j
Comment 3 Kyle Huey [:khuey] (Exited; not receiving bugmail, email if necessary) 2012-07-27 14:07:21 PDT
Comment on attachment 646632 [details] [diff] [review]
Use createInstance to get a new, not singleton, XHR instance on each invocation

Review of attachment 646632 [details] [diff] [review]:
-----------------------------------------------------------------

Yep.
Comment 4 Ed Morley [:emorley] 2012-07-31 06:12:03 PDT
https://hg.mozilla.org/mozilla-central/rev/f6f7358234b3

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