From fac330fb50d1ac9ebc61a1cebfc105a96796195d Mon Sep 17 00:00:00 2001 From: haad Date: Sat, 23 Jul 2016 12:43:49 +0100 Subject: [PATCH] Fix TypedArray check, add check when instanceof doesn't work for TypedArrays. --- lib/browser/rpc-server.js | 2 +- lib/common/api/is-typed-array.js | 3 ++- lib/renderer/api/remote.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/browser/rpc-server.js b/lib/browser/rpc-server.js index 2ee14a6659bc..6e9d80ed21ae 100644 --- a/lib/browser/rpc-server.js +++ b/lib/browser/rpc-server.js @@ -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' diff --git a/lib/common/api/is-typed-array.js b/lib/common/api/is-typed-array.js index 41ca2d9f4b3e..8b63a0cb1b74 100644 --- a/lib/common/api/is-typed-array.js +++ b/lib/common/api/is-typed-array.js @@ -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') ) } diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index 30b94e98841a..ae6564fe0f27 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -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)