08-27-周三_17-09-29
This commit is contained in:
175
node_modules/faye-websocket/spec/faye/websocket/client_spec.js
generated
vendored
Normal file
175
node_modules/faye-websocket/spec/faye/websocket/client_spec.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
var Client = require('../../../lib/faye/websocket/client')
|
||||
|
||||
JS.ENV.WebSocketSteps = JS.Test.asyncSteps({
|
||||
server: function(port, secure, callback) {
|
||||
this._adapter = new EchoServer()
|
||||
this._adapter.listen(port, secure)
|
||||
this._port = port
|
||||
setTimeout(callback, 100)
|
||||
},
|
||||
|
||||
stop: function(callback) {
|
||||
this._adapter.stop()
|
||||
setTimeout(callback, 100)
|
||||
},
|
||||
|
||||
open_socket: function(url, protocols, callback) {
|
||||
var done = false,
|
||||
self = this,
|
||||
|
||||
resume = function(open) {
|
||||
if (done) return
|
||||
done = true
|
||||
self._open = open
|
||||
callback()
|
||||
}
|
||||
|
||||
this._ws = new Client(url, protocols, {verify: false})
|
||||
|
||||
this._ws.onopen = function() { resume(true) }
|
||||
this._ws.onclose = function() { resume(false) }
|
||||
},
|
||||
|
||||
close_socket: function(callback) {
|
||||
var self = this
|
||||
this._ws.onclose = function() {
|
||||
self._open = false
|
||||
callback()
|
||||
}
|
||||
this._ws.close()
|
||||
},
|
||||
|
||||
check_open: function(callback) {
|
||||
this.assert( this._open )
|
||||
callback()
|
||||
},
|
||||
|
||||
check_closed: function(callback) {
|
||||
this.assert( !this._open )
|
||||
callback()
|
||||
},
|
||||
|
||||
check_protocol: function(protocol, callback) {
|
||||
this.assertEqual( protocol, this._ws.protocol )
|
||||
callback()
|
||||
},
|
||||
|
||||
listen_for_message: function(callback) {
|
||||
var self = this
|
||||
this._ws.addEventListener('message', function(message) { self._message = message.data })
|
||||
callback()
|
||||
},
|
||||
|
||||
send_message: function(message, callback) {
|
||||
this._ws.send(message)
|
||||
setTimeout(callback, 100)
|
||||
},
|
||||
|
||||
check_response: function(message, callback) {
|
||||
this.assertEqual( message, this._message )
|
||||
callback()
|
||||
},
|
||||
|
||||
check_no_response: function(callback) {
|
||||
this.assert( !this._message )
|
||||
callback()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
JS.ENV.ClientSpec = JS.Test.describe("Client", function() { with(this) {
|
||||
include(WebSocketSteps)
|
||||
|
||||
before(function() {
|
||||
this.protocols = ["foo", "echo"]
|
||||
this.plain_text_url = "ws://localhost:8000/bayeux"
|
||||
this.secure_url = "wss://localhost:8000/bayeux"
|
||||
})
|
||||
|
||||
sharedBehavior("socket client", function() { with(this) {
|
||||
it("can open a connection", function() { with(this) {
|
||||
open_socket(socket_url, protocols)
|
||||
check_open()
|
||||
check_protocol("echo")
|
||||
}})
|
||||
|
||||
it("cannot open a connection with unacceptable protocols", function() { with(this) {
|
||||
open_socket(socket_url, ["foo"])
|
||||
check_closed()
|
||||
}})
|
||||
|
||||
it("can close the connection", function() { with(this) {
|
||||
open_socket(socket_url, protocols)
|
||||
close_socket()
|
||||
check_closed()
|
||||
}})
|
||||
|
||||
describe("in the OPEN state", function() { with(this) {
|
||||
before(function() { with(this) {
|
||||
open_socket(socket_url, protocols)
|
||||
}})
|
||||
|
||||
it("can send and receive messages", function() { with(this) {
|
||||
listen_for_message()
|
||||
send_message("I expect this to be echoed")
|
||||
check_response("I expect this to be echoed")
|
||||
}})
|
||||
|
||||
it("sends numbers as strings", function() { with(this) {
|
||||
listen_for_message()
|
||||
send_message(13)
|
||||
check_response("13")
|
||||
}})
|
||||
|
||||
it("sends booleans as strings", function() { with(this) {
|
||||
listen_for_message()
|
||||
send_message(false)
|
||||
check_response("false")
|
||||
}})
|
||||
|
||||
it("sends arrays as strings", function() { with(this) {
|
||||
listen_for_message()
|
||||
send_message([13,14,15])
|
||||
check_response("13,14,15")
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("in the CLOSED state", function() { with(this) {
|
||||
before(function() { with(this) {
|
||||
open_socket(socket_url, protocols)
|
||||
close_socket()
|
||||
}})
|
||||
|
||||
it("cannot send and receive messages", function() { with(this) {
|
||||
listen_for_message()
|
||||
send_message("I expect this to be echoed")
|
||||
check_no_response()
|
||||
}})
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("with a plain-text server", function() { with(this) {
|
||||
before(function() {
|
||||
this.socket_url = this.plain_text_url
|
||||
this.blocked_url = this.secure_url
|
||||
})
|
||||
|
||||
before(function() { this.server(8000, false) })
|
||||
after (function() { this.stop() })
|
||||
|
||||
behavesLike("socket client")
|
||||
}})
|
||||
|
||||
describe("with a secure server", function() { with(this) {
|
||||
before(function() {
|
||||
this.socket_url = this.secure_url
|
||||
this.blocked_url = this.plain_text_url
|
||||
})
|
||||
|
||||
before(function() { this.server(8000, true) })
|
||||
after (function() { this.stop() })
|
||||
|
||||
behavesLike("socket client")
|
||||
}})
|
||||
}})
|
||||
|
72
node_modules/faye-websocket/spec/faye/websocket/draft75parser_spec.js
generated
vendored
Normal file
72
node_modules/faye-websocket/spec/faye/websocket/draft75parser_spec.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
var Draft75Parser = require('../../../lib/faye/websocket/draft75_parser')
|
||||
|
||||
JS.ENV.Draft75ParserSpec = JS.Test.describe("Draft75Parser", function() { with(this) {
|
||||
before(function() { with(this) {
|
||||
this.webSocket = {dispatchEvent: function() {}}
|
||||
this.parser = new Draft75Parser(webSocket)
|
||||
}})
|
||||
|
||||
describe("parse", function() { with(this) {
|
||||
sharedBehavior("draft-75 parser", function() { with(this) {
|
||||
it("parses text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parser.parse([0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff])
|
||||
}})
|
||||
|
||||
it("parses multiple frames from the same packet", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello").exactly(2)
|
||||
parser.parse([0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff])
|
||||
}})
|
||||
|
||||
it("parses text frames beginning 0x00-0x7F", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parser.parse([0x66, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff])
|
||||
}})
|
||||
|
||||
it("ignores frames with a length header", function() { with(this) {
|
||||
expect(webSocket, "receive").exactly(0)
|
||||
parser.parse([0x80, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])
|
||||
}})
|
||||
|
||||
it("parses text following an ignored block", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parser.parse([0x80, 0x02, 0x48, 0x65, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff])
|
||||
}})
|
||||
|
||||
it("parses multibyte text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Apple = ")
|
||||
parser.parse([0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff])
|
||||
}})
|
||||
|
||||
it("parses frames received in several packets", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Apple = ")
|
||||
parser.parse([0x00, 0x41, 0x70, 0x70, 0x6c, 0x65])
|
||||
parser.parse([0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff])
|
||||
}})
|
||||
|
||||
it("parses fragmented frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parser.parse([0x00, 0x48, 0x65, 0x6c])
|
||||
parser.parse([0x6c, 0x6f, 0xff])
|
||||
}})
|
||||
}})
|
||||
|
||||
behavesLike("draft-75 parser")
|
||||
|
||||
it("does not close the socket if a 76 close frame is received", function() { with(this) {
|
||||
expect(webSocket, "close").exactly(0)
|
||||
expect(webSocket, "receive").given("")
|
||||
parser.parse([0xFF, 0x00])
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("frame", function() { with(this) {
|
||||
it("returns the given string formatted as a WebSocket frame", function() { with(this) {
|
||||
assertBufferEqual( [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff], parser.frame("Hello") )
|
||||
}})
|
||||
|
||||
it("encodes multibyte characters correctly", function() { with(this) {
|
||||
assertBufferEqual( [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff], parser.frame("Apple = ") )
|
||||
}})
|
||||
}})
|
||||
}})
|
28
node_modules/faye-websocket/spec/faye/websocket/draft76parser_spec.js
generated
vendored
Normal file
28
node_modules/faye-websocket/spec/faye/websocket/draft76parser_spec.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
var Draft76Parser = require('../../../lib/faye/websocket/draft76_parser')
|
||||
|
||||
JS.ENV.Draft76ParserSpec = JS.Test.describe("Draft76Parser", function() { with(this) {
|
||||
before(function() { with(this) {
|
||||
this.webSocket = {dispatchEvent: function() {}}
|
||||
this.parser = new Draft76Parser(webSocket)
|
||||
parser._handshakeComplete = true
|
||||
}})
|
||||
|
||||
describe("parse", function() { with(this) {
|
||||
behavesLike("draft-75 parser")
|
||||
|
||||
it("closes the socket if a close frame is received", function() { with(this) {
|
||||
expect(webSocket, "close")
|
||||
parser.parse([0xFF, 0x00])
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("frame", function() { with(this) {
|
||||
it("returns the given string formatted as a WebSocket frame", function() { with(this) {
|
||||
assertBufferEqual( [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff], parser.frame("Hello") )
|
||||
}})
|
||||
|
||||
it("encodes multibyte characters correctly", function() { with(this) {
|
||||
assertBufferEqual( [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff], parser.frame("Apple = ") )
|
||||
}})
|
||||
}})
|
||||
}})
|
148
node_modules/faye-websocket/spec/faye/websocket/hybi_parser_spec.js
generated
vendored
Normal file
148
node_modules/faye-websocket/spec/faye/websocket/hybi_parser_spec.js
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
var HybiParser = require('../../../lib/faye/websocket/hybi_parser')
|
||||
|
||||
JS.ENV.HybiParserSpec = JS.Test.describe("HybiParser", function() { with(this) {
|
||||
before(function() { with(this) {
|
||||
this.webSocket = {dispatchEvent: function() {}}
|
||||
this.parser = new HybiParser(webSocket)
|
||||
}})
|
||||
|
||||
define("parse", function() {
|
||||
var bytes = [];
|
||||
for (var i = 0, n = arguments.length; i < n; i++) bytes = bytes.concat(arguments[i])
|
||||
this.parser.parse(new Buffer(bytes))
|
||||
})
|
||||
|
||||
define("buffer", function(string) {
|
||||
return {
|
||||
equals: function(buffer) {
|
||||
return buffer.toString('utf8', 0, buffer.length) === string
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
describe("parse", function() { with(this) {
|
||||
define("mask", function() {
|
||||
return this._mask = this._mask || [1,2,3,4].map(function() { return Math.floor(Math.random() * 255) })
|
||||
})
|
||||
|
||||
define("maskMessage", function(bytes) {
|
||||
var output = []
|
||||
Array.prototype.forEach.call(bytes, function(b, i) {
|
||||
output[i] = bytes[i] ^ this.mask()[i % 4]
|
||||
}, this)
|
||||
return output
|
||||
})
|
||||
|
||||
it("parses unmasked text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parse([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])
|
||||
}})
|
||||
|
||||
it("parses multiple frames from the same packet", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello").exactly(2)
|
||||
parse([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])
|
||||
}})
|
||||
|
||||
it("parses empty text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("")
|
||||
parse([0x81, 0x00])
|
||||
}})
|
||||
|
||||
it("parses fragmented text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parse([0x01, 0x03, 0x48, 0x65, 0x6c])
|
||||
parse([0x80, 0x02, 0x6c, 0x6f])
|
||||
}})
|
||||
|
||||
it("parses masked text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parse([0x81, 0x85], mask(), maskMessage([0x48, 0x65, 0x6c, 0x6c, 0x6f]))
|
||||
}})
|
||||
|
||||
it("parses masked empty text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("")
|
||||
parse([0x81, 0x80], mask(), maskMessage([]))
|
||||
}})
|
||||
|
||||
it("parses masked fragmented text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Hello")
|
||||
parse([0x01, 0x81], mask(), maskMessage([0x48]))
|
||||
parse([0x80, 0x84], mask(), maskMessage([0x65, 0x6c, 0x6c, 0x6f]))
|
||||
}})
|
||||
|
||||
it("closes the socket if the frame has an unrecognized opcode", function() { with(this) {
|
||||
expect(webSocket, "close").given(1002, null, false)
|
||||
parse([0x83, 0x00])
|
||||
}})
|
||||
|
||||
it("closes the socket if a close frame is received", function() { with(this) {
|
||||
expect(webSocket, "close").given(1000, "Hello", false)
|
||||
parse([0x88, 0x07, 0x03, 0xe8, 0x48, 0x65, 0x6c, 0x6c, 0x6f])
|
||||
}})
|
||||
|
||||
it("parses unmasked multibyte text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Apple = ")
|
||||
parse([0x81, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf])
|
||||
}})
|
||||
|
||||
it("parses frames received in several packets", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Apple = ")
|
||||
parse([0x81, 0x0b, 0x41, 0x70, 0x70, 0x6c])
|
||||
parse([0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf])
|
||||
}})
|
||||
|
||||
it("parses fragmented multibyte text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Apple = ")
|
||||
parse([0x01, 0x0a, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3])
|
||||
parse([0x80, 0x01, 0xbf])
|
||||
}})
|
||||
|
||||
it("parses masked multibyte text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Apple = ")
|
||||
parse([0x81, 0x8b], mask(), maskMessage([0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf]))
|
||||
}})
|
||||
|
||||
it("parses masked fragmented multibyte text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("Apple = ")
|
||||
parse([0x01, 0x8a], mask(), maskMessage([0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3]))
|
||||
parse([0x80, 0x81], mask(), maskMessage([0xbf]))
|
||||
}})
|
||||
|
||||
it("parses unmasked medium-length text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello")
|
||||
parse([129, 126, 0, 200, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111])
|
||||
}})
|
||||
|
||||
it("parses masked medium-length text frames", function() { with(this) {
|
||||
expect(webSocket, "receive").given("HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello")
|
||||
parse([129, 254, 0, 200], mask(), maskMessage([72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111]))
|
||||
}})
|
||||
|
||||
it("replies to pings with a pong", function() { with(this) {
|
||||
expect(webSocket, "send").given(buffer("OHAI"), "pong")
|
||||
parse([0x89, 0x04, 0x4f, 0x48, 0x41, 0x49])
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("frame", function() { with(this) {
|
||||
it("returns the given string formatted as a WebSocket frame", function() { with(this) {
|
||||
assertBufferEqual( [0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f], parser.frame("Hello") )
|
||||
}})
|
||||
|
||||
it("encodes multibyte characters correctly", function() { with(this) {
|
||||
assertBufferEqual( [0x81, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf], parser.frame("Apple = ") )
|
||||
}})
|
||||
|
||||
it("encodes medium-length strings using extra length bytes", function() { with(this) {
|
||||
assertBufferEqual( [129, 126, 0, 200, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111], parser.frame("HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello") )
|
||||
}})
|
||||
|
||||
it("encodes close frames with an error code", function() { with(this) {
|
||||
assertBufferEqual( [0x88, 0x07, 0x03, 0xea, 0x48, 0x65, 0x6c, 0x6c, 0x6f], parser.frame("Hello", "close", 1002) )
|
||||
}})
|
||||
|
||||
it("encodes pong frames", function() { with(this) {
|
||||
assertBufferEqual( [0x8a, 0x00], parser.frame("", "pong") )
|
||||
}})
|
||||
}})
|
||||
}})
|
54
node_modules/faye-websocket/spec/runner.js
generated
vendored
Normal file
54
node_modules/faye-websocket/spec/runner.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
require('jsclass')
|
||||
|
||||
var WebSocket = require('../lib/faye/websocket'),
|
||||
fs = require('fs'),
|
||||
http = require('http'),
|
||||
https = require('https')
|
||||
|
||||
|
||||
JS.ENV.EchoServer = function() {}
|
||||
EchoServer.prototype.listen = function(port, ssl) {
|
||||
var server = ssl
|
||||
? https.createServer({
|
||||
key: fs.readFileSync(__dirname + '/server.key'),
|
||||
cert: fs.readFileSync(__dirname + '/server.crt')
|
||||
})
|
||||
: http.createServer()
|
||||
|
||||
server.addListener('upgrade', function(request, socket, head) {
|
||||
var ws = new WebSocket(request, socket, head, ["echo"])
|
||||
ws.onmessage = function(event) {
|
||||
ws.send(event.data)
|
||||
}
|
||||
})
|
||||
this._httpServer = server
|
||||
server.listen(port)
|
||||
}
|
||||
EchoServer.prototype.stop = function(callback, scope) {
|
||||
this._httpServer.addListener('close', function() {
|
||||
if (callback) callback.call(scope);
|
||||
});
|
||||
this._httpServer.close();
|
||||
}
|
||||
|
||||
|
||||
JS.Packages(function() { with(this) {
|
||||
autoload(/.*Spec/, {from: 'spec/faye/websocket'})
|
||||
}})
|
||||
|
||||
|
||||
JS.require('JS.Test', function() {
|
||||
JS.Test.Unit.Assertions.define("assertBufferEqual", function(array, buffer) {
|
||||
this.assertEqual(array.length, buffer.length);
|
||||
var ary = [], n = buffer.length;
|
||||
while (n--) ary[n] = buffer[n];
|
||||
this.assertEqual(array, ary);
|
||||
})
|
||||
|
||||
JS.require( 'ClientSpec',
|
||||
'Draft75ParserSpec',
|
||||
'Draft76ParserSpec',
|
||||
'HybiParserSpec',
|
||||
JS.Test.method('autorun'))
|
||||
})
|
||||
|
15
node_modules/faye-websocket/spec/server.crt
generated
vendored
Normal file
15
node_modules/faye-websocket/spec/server.crt
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICZTCCAc4CCQDxyrJZrFA0vjANBgkqhkiG9w0BAQUFADB3MQswCQYDVQQGEwJV
|
||||
SzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24xDTALBgNVBAoTBEZh
|
||||
eWUxFTATBgNVBAMTDEphbWVzIENvZ2xhbjEgMB4GCSqGSIb3DQEJARYRamNvZ2xh
|
||||
bkBnbWFpbC5jb20wHhcNMTEwODMwMTIzOTM2WhcNMTIwODI5MTIzOTM2WjB3MQsw
|
||||
CQYDVQQGEwJVSzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24xDTAL
|
||||
BgNVBAoTBEZheWUxFTATBgNVBAMTDEphbWVzIENvZ2xhbjEgMB4GCSqGSIb3DQEJ
|
||||
ARYRamNvZ2xhbkBnbWFpbC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
|
||||
AMDjU5fAK7fvUCZIYHcGXDZD/m9bY+B/UcwGcowk0hMQGYNlLKrpiK7xXBmZpDb6
|
||||
r8n+7L/epBeSumbRIm4TDzeNHhuQGYLIeGQy7JNLoPBr6GxubjuJhKOOBnCqcupR
|
||||
CLGG7Zw5oL4UvtZVH6kL9XnjyokQQbxxeoV9DqtqOaHHAgMBAAEwDQYJKoZIhvcN
|
||||
AQEFBQADgYEAvQjSpzE1ahaeH1CmbLwckTxvWMZfxcZOrxTruK1po3cNnDOjGqFQ
|
||||
KEkNj3K5WfwTBD4QgUdYDykhDX2m6HaMz4JEbgrwQv8M8FiswIA3dyGsbOifOk8H
|
||||
r3GPNKMzm4o6vrn6RGOpt9q6bsWUBUHfNpP93uU2C9QEwDua3cFjDA0=
|
||||
-----END CERTIFICATE-----
|
15
node_modules/faye-websocket/spec/server.key
generated
vendored
Normal file
15
node_modules/faye-websocket/spec/server.key
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQDA41OXwCu371AmSGB3Blw2Q/5vW2Pgf1HMBnKMJNITEBmDZSyq
|
||||
6Yiu8VwZmaQ2+q/J/uy/3qQXkrpm0SJuEw83jR4bkBmCyHhkMuyTS6Dwa+hsbm47
|
||||
iYSjjgZwqnLqUQixhu2cOaC+FL7WVR+pC/V548qJEEG8cXqFfQ6rajmhxwIDAQAB
|
||||
AoGABlk1DiCQD8y7mZb2PdSiwlJ4lFewsNnf6lQn/v7TPzdfb5ir4LAxBHkDLACH
|
||||
jBuyH3bZefMs+W2l3u5xMKhF7uJqYcUlJdH2UwRfNG54Hn4SGAjQOK3ONer99sUf
|
||||
USlsWSX1HjAAFMCBwUfKxMZA3VNQfYKTPdm0jSVf85kHO1ECQQD3s6ksm3QpfD0L
|
||||
eG9EoDrqmwnEfpKoWPpz1O0i5tY9VcmhmLwS5Zpd7lB1qjTqzZk4RygU73T/BseJ
|
||||
azehIHK5AkEAx1mSXt+ec8RfzVi/io6oqi2vOcACXRbOG4NQmqUWPnumdwsJjsjR
|
||||
RzEoDFC2lu6448p9sgEq+CkbmgVeiyp4fwJAQnmgySve/NMuvslPcyddKGD7OhSN
|
||||
30ghzrwx98/jZwqC1i9bKeccimDOjwVitjD/Ea9m/ldVGqwDGMoBX+iJYQJAEIOO
|
||||
CYfyw1pQKV2huGOq+zX/nwQV7go2lrbhFX55gkGR/6iNaSOfmosq6yJAje5GqLAc
|
||||
i4NnQNl+7NpnA5ZIFwJBAI1+OsZyjbRI99pYkTdOpa5IPlIb3j3JbSfjAWHLxlRY
|
||||
0HLvN3Q1mE9kbB+uKH6syF/S7nALgsLgq7eHYvIaE/A=
|
||||
-----END RSA PRIVATE KEY-----
|
Reference in New Issue
Block a user