Fix TypedArray check, add check when instanceof doesn't work for TypedArrays.
authorhaad <haad@headbanggames.com>
Sat, 23 Jul 2016 11:43:49 +0000 (12:43 +0100)
committerhaad <haad@headbanggames.com>
Sat, 23 Jul 2016 11:43:49 +0000 (12:43 +0100)
lib/browser/rpc-server.js
lib/common/api/is-typed-array.js
lib/renderer/api/remote.js

index 2ee14a6..6e9d80e 100644 (file)
@@ -63,7 +63,7 @@ let valueToMeta = function (sender, value, optimizeSimpleObject = false) {
       meta.type = 'buffer'
     } else if (Array.isArray(value)) {
       meta.type = 'array'
-    } else if (isTypedArray(value.buffer)) {
+    } else if (isTypedArray(value)) {
       meta.type = 'typed-array'
     } else if (value instanceof Error) {
       meta.type = 'error'
index 41ca2d9..8b63a0c 100644 (file)
@@ -11,6 +11,7 @@ module.exports = function isTypedArray (val) {
      val instanceof Uint16Array ||
      val instanceof Uint32Array ||
      val instanceof Float32Array ||
-     val instanceof Float64Array)
+     val instanceof Float64Array) ||
+    (Object.prototype.toString.call(val).substr(-6, 5) === 'Array')
   )
 }
index 30b94e9..ae6564f 100644 (file)
@@ -35,7 +35,7 @@ const wrapArgs = function (args, visited) {
         type: 'buffer',
         value: Array.prototype.slice.call(value, 0)
       }
-    } else if (isTypedArray(value.buffer)) {
+    } else if (isTypedArray(value)) {
       return {
         type: 'typed-array',
         value: Array.prototype.slice.call(value)