Derive WebSocket protocol from document's protocol

Use an insecure WebSocket connection when the page is served over HTTP,
but use a secure WebSocket connection when the page is served over
HTTPS.