Created attachment 626332 [details] [diff] [review] Releases ref to listener after calling OnStop. Necko channels generally have a contract where they release their ref to the listener after the last callback is completed (OnStopRequest: for nsIWebSocketListener, this would be OnStop). But we're not doing this now in WebSocketChannel, and are instead keeping a ref until the necko channel is destroyed, which puts the onus on the listener to make sure it doesn't have a cyclic reference. The current code works (nsIWebSocket releases its ref in Disconnect), and I don't want to actually land this until I've had a chance to look into whether it might break things--it passes mochitests fine on my box, though, FWIW.
Comment on attachment 626332 [details] [diff] [review] Releases ref to listener after calling OnStop. all uses of mListener should be protected by mStopped, so that's ought to be fine.