]> zoso.dev Git - buffer.git/commitdiff
test expected browsers get Uint8Array implementation
authorFeross Aboukhadijeh <feross@feross.org>
Thu, 8 May 2014 00:46:04 +0000 (17:46 -0700)
committerFeross Aboukhadijeh <feross@feross.org>
Thu, 8 May 2014 00:46:04 +0000 (17:46 -0700)
Fixes #25

package.json
test/user-agent.js [new file with mode: 0644]

index 42c3cef62bb5ace005a160c22fed8598078bd7e7..84f6d485ffa7b8e548cc1a73ee9b8c21134a0adc 100644 (file)
     "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 (file)
index 0000000..1bfaebd
--- /dev/null
@@ -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()
+})