]> khamidou — GitHub mirrors - electron.git/commitdiff
Use constructor name to check if Promise
authorRyohei Ikegami <iofg2100@gmail.com>
Sat, 1 Aug 2015 03:20:16 +0000 (12:20 +0900)
committerRyohei Ikegami <iofg2100@gmail.com>
Sat, 1 Aug 2015 03:20:16 +0000 (12:20 +0900)
atom/browser/lib/rpc-server.coffee
atom/renderer/api/lib/remote.coffee

index 8c96718166311628bf43bb6d7965bfad1dbe3916..3eba472570a7551b6a5e3d4539a2392b976b47c5 100644 (file)
@@ -10,7 +10,7 @@ valueToMeta = (sender, value) ->
   meta.type = 'buffer' if Buffer.isBuffer value
   meta.type = 'value' if value is null
   meta.type = 'array' if Array.isArray value
-  meta.type = 'promise' if Promise.resolve(value) == value
+  meta.type = 'promise' if value? and value.constructor.name is 'Promise'
 
   # Treat the arguments object as array.
   meta.type = 'array' if meta.type is 'object' and value.callee? and value.length?
index 7370440c6c2d7fdc8e12a53f693e5e5ab385cc08..29a24b1789ef8927bb42b3e9960d305e66a86544 100644 (file)
@@ -20,7 +20,7 @@ wrapArgs = (args, visited=[]) ->
       type: 'array', value: wrapArgs(value, visited)
     else if Buffer.isBuffer value
       type: 'buffer', value: Array::slice.call(value, 0)
-    else if Promise.resolve(value) == value
+    else if value? and value.constructor.name is 'Promise'
       type: 'promise', then: valueToMeta(value.then.bind(value))
     else if value? and typeof value is 'object' and v8Util.getHiddenValue value, 'atomId'
       type: 'remote-object', id: v8Util.getHiddenValue value, 'atomId'