A call to mozTCPSocket::listen fails if the port is already used. The error logged to the console is quite uninformative ("uncaught exception: out of memory error", or something like this). We should improve this message.
If I run the same code in the privileged about:newtab, I can see the following: [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.init]" nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)" location: "JS frame :: resource://gre/components/TCPServerSocket.js :: tss_listen :: line 105" data: no]
I also ran into this when writing examples for mozTcpSocket.listen. Without this bug I wouldn't have known why I see "out of memory". Is this really so hard to fix that it has to be ignored?
I suspect yes - from a privileged context, the error appears to be reported just fine. That implies that the error is getting masked by the code that handles exposing JS-implemented IDL to unprivileged contexts, which is stuff that very few people have experience digging into. I think the situation should be easier to assess after bug 885982.