]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: Test user agent in websocket
authorCheng Zhao <zcbenz@gmail.com>
Tue, 14 Jul 2015 18:38:30 +0000 (11:38 -0700)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 14 Jul 2015 18:39:41 +0000 (11:39 -0700)
spec/chromium-spec.coffee
spec/package.json

index 88a3487cc9d28a31dc4d5d156870f57d50616bc8..8ca7e9800fe509abb66ca9fbb59409e171f97cd5 100644 (file)
@@ -2,6 +2,7 @@ assert = require 'assert'
 http = require 'http'
 https = require 'https'
 path = require 'path'
+ws = require 'ws'
 
 describe 'chromium feature', ->
   fixtures = path.resolve __dirname, 'fixtures'
@@ -88,3 +89,25 @@ describe 'chromium feature', ->
       navigator.webkitPersistentStorage.requestQuota 1024 * 1024, (grantedBytes) ->
         assert.equal grantedBytes, 1048576
         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}")
index 6e9489e601d82658768aa446c621a25f66b97f5c..6343832dcc8ee93b8228616478a44b40524aa250 100644 (file)
@@ -11,6 +11,7 @@
     "q": "0.9.7",
     "runas": "2.x",
     "temp": "0.8.1",
-    "walkdir": "0.0.7"
+    "walkdir": "0.0.7",
+    "ws": "0.7.2"
   }
 }