Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What should happen when the WebSocket constructor is called for a global whose document is not current? #22

Open
bzbarsky opened this issue Dec 8, 2016 · 2 comments

Comments

@bzbarsky
Copy link

bzbarsky commented Dec 8, 2016

As far as I can tell, the spec requires that the constructor work and return a websocket, and this websocket try to connect and whatnot. But I don't see what would ever shut down that connection, once established. Websocket connections are normally shut down during navigation, but only the ones corresponding to the global being unloaded, and we're past that step for this global.

See http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4721 for a kinda testcase, though it's using a websocket to something that doesn't speak websocket, so doesn't actually end up with a connection.

In terms of UA behavior, Firefox throws from the constructor in this situation. Chrome creates the object, but it behaves in what look like spec-violating ways (e.g. transitions from the CONNECTING state to the CLOSED state without firing a "close" event as far as I can tell). I haven't tested other UAs, or what happens if the URL used points to an actual websocket endpoint.

@bzbarsky
Copy link
Author

bzbarsky commented Dec 8, 2016

Note that it's not clear to me how consistently Firefox throws here. It does in this specific testcase, but I'm not sure it would if page being unloaded had gone into bfcache (which subframe navigations never do in Gecko).

@annevk
Copy link
Member

annevk commented Dec 16, 2016

I guess ideally we make this behave similar to what XMLHttpRequest does in https://xhr.spec.whatwg.org/#dom-xmlhttprequest-open, right? Would be good to have tests though.

@domenic domenic transferred this issue from whatwg/html Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants