spec: Test user agent in websocket
This commit is contained in:
parent
3ffd774405
commit
56dfef8d0d
2 changed files with 25 additions and 1 deletions
|
@ -2,6 +2,7 @@ assert = require 'assert'
|
||||||
http = require 'http'
|
http = require 'http'
|
||||||
https = require 'https'
|
https = require 'https'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
|
ws = require 'ws'
|
||||||
|
|
||||||
describe 'chromium feature', ->
|
describe 'chromium feature', ->
|
||||||
fixtures = path.resolve __dirname, 'fixtures'
|
fixtures = path.resolve __dirname, 'fixtures'
|
||||||
|
@ -88,3 +89,25 @@ describe 'chromium feature', ->
|
||||||
navigator.webkitPersistentStorage.requestQuota 1024 * 1024, (grantedBytes) ->
|
navigator.webkitPersistentStorage.requestQuota 1024 * 1024, (grantedBytes) ->
|
||||||
assert.equal grantedBytes, 1048576
|
assert.equal grantedBytes, 1048576
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
describe 'websockets', ->
|
||||||
|
wss = null
|
||||||
|
server = null
|
||||||
|
WebSocketServer = ws.Server
|
||||||
|
|
||||||
|
afterEach ->
|
||||||
|
wss.close()
|
||||||
|
server.close()
|
||||||
|
|
||||||
|
it 'has user agent', (done) ->
|
||||||
|
server = http.createServer()
|
||||||
|
server.listen 0, '127.0.0.1', ->
|
||||||
|
port = server.address().port
|
||||||
|
wss = new WebSocketServer(server: server)
|
||||||
|
wss.on 'error', done
|
||||||
|
wss.on 'connection', (ws) ->
|
||||||
|
if ws.upgradeReq.headers['user-agent']
|
||||||
|
done()
|
||||||
|
else
|
||||||
|
done('user agent is empty')
|
||||||
|
websocket = new WebSocket("ws://127.0.0.1:#{port}")
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"q": "0.9.7",
|
"q": "0.9.7",
|
||||||
"runas": "2.x",
|
"runas": "2.x",
|
||||||
"temp": "0.8.1",
|
"temp": "0.8.1",
|
||||||
"walkdir": "0.0.7"
|
"walkdir": "0.0.7",
|
||||||
|
"ws": "0.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue