]> khamidou — GitHub mirrors - electron.git/commitdiff
:lipstick: Fix protocol specs.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 30 Aug 2013 05:04:02 +0000 (13:04 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 30 Aug 2013 05:04:02 +0000 (13:04 +0800)
browser/api/atom_api_protocol.cc
spec/api/protocol.coffee

index abeac812b5595e62a42f31337a9f6df6dc3c2199..70611ea32bbd64752a2049e595e6c4bf00844c3f 100644 (file)
@@ -291,7 +291,8 @@ class AdapterProtocolHandler
 // static
 v8::Handle<v8::Value> Protocol::RegisterProtocol(const v8::Arguments& args) {
   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");
 
   // Store the handler in a map.
index ab90cb9018a25bf8a40fa013391dc24528d5ebb6..027e622c36c45e9f47a2e464668568bda2d5f9c3 100644 (file)
@@ -5,11 +5,14 @@ protocol = remote.require 'protocol'
 
 describe 'protocol API', ->
   describe 'protocol.registerProtocol', ->
-    it 'throws error when scheme is already registered', ->
+    it 'throws error when scheme is already registered', (done) ->
       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()
-      assert.throws register, /The scheme is already registered/
-      protocol.unregisterProtocol 'test1'
 
     it 'calls the callback when scheme is visited', (done) ->
       protocol.registerProtocol 'test2', (request) ->