From c5c3fdb1994bc469cd5d28d1e5ac757808c4b4d6 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 7 May 2014 17:46:04 -0700 Subject: [PATCH] test expected browsers get Uint8Array implementation Fixes #25 --- package.json | 7 ++++--- test/user-agent.js | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 test/user-agent.js diff --git a/package.json b/package.json index 42c3cef..84f6d48 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,10 @@ "ieee754": "~1.1.1" }, "devDependencies": { - "benchmark": "1.x", - "browserify": "3.x", - "tape": "2.x" + "benchmark": "^1.0.0", + "browserify": "^3.46.0", + "tape": "^2.12.3", + "useragent": "^2.0.8" }, "homepage": "http://feross.org", "keywords": [ diff --git a/test/user-agent.js b/test/user-agent.js new file mode 100644 index 0000000..1bfaebd --- /dev/null +++ b/test/user-agent.js @@ -0,0 +1,26 @@ +var B = require('../').Buffer +var test = require('tape') +var useragent = require('useragent') + +test('expected browsers get Uint8Array implementation', function (t) { + if (typeof navigator === 'undefined') { + t.pass('Not running in a browser -- skip this test') + t.end() + return + } + var agent = useragent.parse(navigator.userAgent) + console.log('Family: ' + agent.family) + console.log('Version: ' + agent.major + '.' + agent.minor) + + if ((agent.family === 'Chrome' && agent.major >= 7) || + (agent.family === 'Internet Explorer' && agent.major >= 10) || + (agent.family === 'Firefox' && agent.major >= 30) || + (agent.family === 'Opera' && agent.major >= 12) || + (agent.family === 'Safari' && agent.major === 5 && agent.minor === 1) || + (agent.family === 'Safari' && agent.major === 6)) { + t.ok(B._useTypedArrays) + } else { + t.ok(!B._useTypedArrays) + } + t.end() +}) -- 2.34.1