From: Feross Aboukhadijeh Date: Thu, 8 May 2014 00:46:04 +0000 (-0700) Subject: test expected browsers get Uint8Array implementation X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=c5c3fdb1994bc469cd5d28d1e5ac757808c4b4d6;p=buffer.git test expected browsers get Uint8Array implementation Fixes #25 --- 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() +})