💄 Fix protocol specs.
This commit is contained in:
parent
11221979e5
commit
738cbd4080
2 changed files with 8 additions and 4 deletions
|
@ -291,7 +291,8 @@ class AdapterProtocolHandler
|
||||||
// static
|
// static
|
||||||
v8::Handle<v8::Value> Protocol::RegisterProtocol(const v8::Arguments& args) {
|
v8::Handle<v8::Value> Protocol::RegisterProtocol(const v8::Arguments& args) {
|
||||||
std::string scheme(*v8::String::Utf8Value(args[0]));
|
std::string scheme(*v8::String::Utf8Value(args[0]));
|
||||||
if (net::URLRequest::IsHandledProtocol(scheme))
|
if (g_handlers.find(scheme) != g_handlers.end() ||
|
||||||
|
net::URLRequest::IsHandledProtocol(scheme))
|
||||||
return node::ThrowError("The scheme is already registered");
|
return node::ThrowError("The scheme is already registered");
|
||||||
|
|
||||||
// Store the handler in a map.
|
// Store the handler in a map.
|
||||||
|
|
|
@ -5,11 +5,14 @@ protocol = remote.require 'protocol'
|
||||||
|
|
||||||
describe 'protocol API', ->
|
describe 'protocol API', ->
|
||||||
describe 'protocol.registerProtocol', ->
|
describe 'protocol.registerProtocol', ->
|
||||||
it 'throws error when scheme is already registered', ->
|
it 'throws error when scheme is already registered', (done) ->
|
||||||
register = -> protocol.registerProtocol('test1', ->)
|
register = -> protocol.registerProtocol('test1', ->)
|
||||||
|
protocol.once 'registered', (scheme) ->
|
||||||
|
assert.equal scheme, 'test1'
|
||||||
|
assert.throws register, /The scheme is already registered/
|
||||||
|
protocol.unregisterProtocol 'test1'
|
||||||
|
done()
|
||||||
register()
|
register()
|
||||||
assert.throws register, /The scheme is already registered/
|
|
||||||
protocol.unregisterProtocol 'test1'
|
|
||||||
|
|
||||||
it 'calls the callback when scheme is visited', (done) ->
|
it 'calls the callback when scheme is visited', (done) ->
|
||||||
protocol.registerProtocol 'test2', (request) ->
|
protocol.registerProtocol 'test2', (request) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue