Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e60ce5fb99 | |||
| 9390b50f0d | |||
| 01e6e83bf9 | |||
| 00bed7dc11 | |||
| 6bdba6c1ae | |||
| faeca6025b | |||
| 00a4d3a5a8 | |||
| 270011d074 | |||
| 6f81d63645 | |||
| bd3cd9b7ce | |||
| 4c2fd5a65d | |||
| 0887fcf0b4 | |||
| 2a8467dd84 | |||
| 983a99ca6c | |||
| 718f5127ec | |||
| 65aed45b2d | |||
| 05dd964945 | |||
| 4f73bb1a3c |
+2
-3
@@ -9,14 +9,13 @@ browsers:
|
||||
- name: MicrosoftEdge
|
||||
version: 13..latest
|
||||
- name: ie
|
||||
version: 9..latest
|
||||
version: 11
|
||||
- name: iphone
|
||||
version: '9.3..latest'
|
||||
- name: android
|
||||
version: '4.4..6.0' # TODO: change this back to latest once https://github.com/airtap/browsers/issues/3 is fixed
|
||||
version: '6.0..6.0' # TODO: change this back to latest once https://github.com/airtap/browsers/issues/3 is fixed
|
||||
server: ./test/server/index.js
|
||||
scripts:
|
||||
- "/ie8-polyfill.js"
|
||||
- "/test-polyfill.js"
|
||||
browserify:
|
||||
- options:
|
||||
|
||||
@@ -22,23 +22,13 @@ has to be held in memory at once:
|
||||
* Chrome >= 43 (using the `fetch` API)
|
||||
* Firefox >= 9 (using `moz-chunked-arraybuffer` responseType with xhr)
|
||||
|
||||
The following browsers support pseudo-streaming, where the data is available before the
|
||||
request finishes, but the entire response must be held in memory:
|
||||
* Chrome
|
||||
* Safari >= 5, and maybe older
|
||||
* IE >= 10
|
||||
* Most other Webkit-based browsers, including the default Android browser
|
||||
All other supported browsers support pseudo-streaming, where the data is available before
|
||||
the request finishes, but the entire response must be held in memory. This works for both
|
||||
text and binary data.
|
||||
|
||||
All browsers newer than IE8 support binary responses. All of the above browsers that
|
||||
support true streaming or pseudo-streaming support that for binary data as well
|
||||
except for IE10. Old (presto-based) Opera also does not support binary streaming either.
|
||||
|
||||
### IE8 note:
|
||||
As of version 2.0.0, IE8 support requires the user to supply polyfills for
|
||||
`Object.keys`, `Array.prototype.forEach`, and `Array.prototype.indexOf`. Example
|
||||
implementations are provided in [ie8-polyfill.js](ie8-polyfill.js); alternately,
|
||||
you may want to consider using [es5-shim](https://github.com/es-shims/es5-shim).
|
||||
All browsers with full ES5 support shouldn't require any polyfills.
|
||||
### IE note:
|
||||
As of version 3.0.0, IE10 and below are no longer supported. IE11 support will remain for
|
||||
now.
|
||||
|
||||
## How do you use it?
|
||||
|
||||
@@ -132,12 +122,14 @@ that run in the browser (found in `test/browser`). Normally the browser tests ru
|
||||
|
||||
Running `npm test` will run both sets of tests, but in order for the Sauce Labs tests to run
|
||||
you will need to sign up for an account (free for open source projects) and put the
|
||||
credentials in a [`.zuulrc` file](https://github.com/defunctzombie/zuul/wiki/zuulrc).
|
||||
credentials in a [`.airtaprc` file](https://github.com/airtap/airtap/blob/master/doc/airtaprc.md).
|
||||
You will also need to run a [Sauce Connect Proxy](https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy)
|
||||
with the same credentials.
|
||||
|
||||
To run just the Node tests, run `npm run test-node`.
|
||||
|
||||
To run the browser tests locally, run `npm run test-browser-local` and point your browser to
|
||||
`http://localhost:8080/__zuul`
|
||||
the link shown in your terminal.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
// These polyfills taken from MDN (developer.mozilla.org)
|
||||
|
||||
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
|
||||
if (!Object.keys) {
|
||||
Object.keys = (function() {
|
||||
'use strict';
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
|
||||
dontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
dontEnumsLength = dontEnums.length;
|
||||
|
||||
return function(obj) {
|
||||
if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
|
||||
throw new TypeError('Object.keys called on non-object');
|
||||
}
|
||||
|
||||
var result = [], prop, i;
|
||||
|
||||
for (prop in obj) {
|
||||
if (hasOwnProperty.call(obj, prop)) {
|
||||
result.push(prop);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (i = 0; i < dontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(obj, dontEnums[i])) {
|
||||
result.push(dontEnums[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}());
|
||||
}
|
||||
|
||||
// Production steps of ECMA-262, Edition 5, 15.4.4.18
|
||||
// Reference: http://es5.github.io/#x15.4.4.18
|
||||
if (!Array.prototype.forEach) {
|
||||
|
||||
Array.prototype.forEach = function(callback, thisArg) {
|
||||
|
||||
var T, k;
|
||||
|
||||
if (this == null) {
|
||||
throw new TypeError(' this is null or not defined');
|
||||
}
|
||||
|
||||
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
||||
var O = Object(this);
|
||||
|
||||
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
||||
// 3. Let len be ToUint32(lenValue).
|
||||
var len = O.length >>> 0;
|
||||
|
||||
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
||||
// See: http://es5.github.com/#x9.11
|
||||
if (typeof callback !== "function") {
|
||||
throw new TypeError(callback + ' is not a function');
|
||||
}
|
||||
|
||||
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||
if (arguments.length > 1) {
|
||||
T = thisArg;
|
||||
}
|
||||
|
||||
// 6. Let k be 0
|
||||
k = 0;
|
||||
|
||||
// 7. Repeat, while k < len
|
||||
while (k < len) {
|
||||
|
||||
var kValue;
|
||||
|
||||
// a. Let Pk be ToString(k).
|
||||
// This is implicit for LHS operands of the in operator
|
||||
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
||||
// This step can be combined with c
|
||||
// c. If kPresent is true, then
|
||||
if (k in O) {
|
||||
|
||||
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
||||
kValue = O[k];
|
||||
|
||||
// ii. Call the Call internal method of callback with T as the this value and
|
||||
// argument list containing kValue, k, and O.
|
||||
callback.call(T, kValue, k, O);
|
||||
}
|
||||
// d. Increase k by 1.
|
||||
k++;
|
||||
}
|
||||
// 8. return undefined
|
||||
};
|
||||
}
|
||||
|
||||
// Production steps of ECMA-262, Edition 5, 15.4.4.14
|
||||
// Reference: http://es5.github.io/#x15.4.4.14
|
||||
if (!Array.prototype.indexOf) {
|
||||
Array.prototype.indexOf = function(searchElement, fromIndex) {
|
||||
|
||||
var k;
|
||||
|
||||
// 1. Let O be the result of calling ToObject passing
|
||||
// the this value as the argument.
|
||||
if (this == null) {
|
||||
throw new TypeError('"this" is null or not defined');
|
||||
}
|
||||
|
||||
var O = Object(this);
|
||||
|
||||
// 2. Let lenValue be the result of calling the Get
|
||||
// internal method of O with the argument "length".
|
||||
// 3. Let len be ToUint32(lenValue).
|
||||
var len = O.length >>> 0;
|
||||
|
||||
// 4. If len is 0, return -1.
|
||||
if (len === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 5. If argument fromIndex was passed let n be
|
||||
// ToInteger(fromIndex); else let n be 0.
|
||||
var n = +fromIndex || 0;
|
||||
|
||||
if (Math.abs(n) === Infinity) {
|
||||
n = 0;
|
||||
}
|
||||
|
||||
// 6. If n >= len, return -1.
|
||||
if (n >= len) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 7. If n >= 0, then Let k be n.
|
||||
// 8. Else, n<0, Let k be len - abs(n).
|
||||
// If k is less than 0, then let k be 0.
|
||||
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
|
||||
|
||||
// 9. Repeat, while k < len
|
||||
while (k < len) {
|
||||
// a. Let Pk be ToString(k).
|
||||
// This is implicit for LHS operands of the in operator
|
||||
// b. Let kPresent be the result of calling the
|
||||
// HasProperty internal method of O with argument Pk.
|
||||
// This step can be combined with c
|
||||
// c. If kPresent is true, then
|
||||
// i. Let elementK be the result of calling the Get
|
||||
// internal method of O with the argument ToString(k).
|
||||
// ii. Let same be the result of applying the
|
||||
// Strict Equality Comparison Algorithm to
|
||||
// searchElement and elementK.
|
||||
// iii. If same is true, return k.
|
||||
if (k in O && O[k] === searchElement) {
|
||||
return k;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
+3
-17
@@ -4,12 +4,6 @@ exports.writableStream = isFunction(global.WritableStream)
|
||||
|
||||
exports.abortController = isFunction(global.AbortController)
|
||||
|
||||
exports.blobConstructor = false
|
||||
try {
|
||||
new Blob([new ArrayBuffer(1)])
|
||||
exports.blobConstructor = true
|
||||
} catch (e) {}
|
||||
|
||||
// The xhr request to example.com may violate some restrictive CSP configurations,
|
||||
// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
|
||||
// and assume support for certain features below.
|
||||
@@ -45,27 +39,19 @@ function checkTypeSupport (type) {
|
||||
return false
|
||||
}
|
||||
|
||||
// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
|
||||
// Safari 7.1 appears to have fixed this bug.
|
||||
var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
|
||||
var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
|
||||
|
||||
// If fetch is supported, then arraybuffer will be supported too. Skip calling
|
||||
// checkTypeSupport(), since that calls getXHR().
|
||||
exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'))
|
||||
exports.arraybuffer = exports.fetch || checkTypeSupport('arraybuffer')
|
||||
|
||||
// These next two tests unavoidably show warnings in Chrome. Since fetch will always
|
||||
// be used if it's available, just return false for these to avoid the warnings.
|
||||
exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
|
||||
exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
|
||||
checkTypeSupport('moz-chunked-arraybuffer')
|
||||
exports.msstream = !exports.fetch && checkTypeSupport('ms-stream')
|
||||
exports.mozchunkedarraybuffer = !exports.fetch && checkTypeSupport('moz-chunked-arraybuffer')
|
||||
|
||||
// If fetch is supported, then overrideMimeType will be supported too. Skip calling
|
||||
// getXHR().
|
||||
exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
|
||||
|
||||
exports.vbArray = isFunction(global.VBArray)
|
||||
|
||||
function isFunction (value) {
|
||||
return typeof value === 'function'
|
||||
}
|
||||
|
||||
+6
-19
@@ -2,7 +2,6 @@ var capability = require('./capability')
|
||||
var inherits = require('inherits')
|
||||
var response = require('./response')
|
||||
var stream = require('readable-stream')
|
||||
var toArrayBuffer = require('to-arraybuffer')
|
||||
|
||||
var IncomingMessage = response.IncomingMessage
|
||||
var rStates = response.readyStates
|
||||
@@ -16,8 +15,6 @@ function decideMode (preferBinary, useFetch) {
|
||||
return 'ms-stream'
|
||||
} else if (capability.arraybuffer && preferBinary) {
|
||||
return 'arraybuffer'
|
||||
} else if (capability.vbArray && preferBinary) {
|
||||
return 'text:vbarray'
|
||||
} else {
|
||||
return 'text'
|
||||
}
|
||||
@@ -31,7 +28,7 @@ var ClientRequest = module.exports = function (opts) {
|
||||
self._body = []
|
||||
self._headers = {}
|
||||
if (opts.auth)
|
||||
self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
|
||||
self.setHeader('Authorization', 'Basic ' + Buffer.from(opts.auth).toString('base64'))
|
||||
Object.keys(opts.headers).forEach(function (name) {
|
||||
self.setHeader(name, opts.headers[name])
|
||||
})
|
||||
@@ -102,19 +99,10 @@ ClientRequest.prototype._onFinish = function () {
|
||||
var headersObj = self._headers
|
||||
var body = null
|
||||
if (opts.method !== 'GET' && opts.method !== 'HEAD') {
|
||||
if (capability.arraybuffer) {
|
||||
body = toArrayBuffer(Buffer.concat(self._body))
|
||||
} else if (capability.blobConstructor) {
|
||||
body = new global.Blob(self._body.map(function (buffer) {
|
||||
return toArrayBuffer(buffer)
|
||||
}), {
|
||||
type: (headersObj['content-type'] || {}).value || ''
|
||||
})
|
||||
} else {
|
||||
// get utf8 string
|
||||
body = Buffer.concat(self._body).toString()
|
||||
}
|
||||
}
|
||||
body = new Blob(self._body, {
|
||||
type: (headersObj['content-type'] || {}).value || ''
|
||||
});
|
||||
}
|
||||
|
||||
// create flattened list of headers
|
||||
var headersList = []
|
||||
@@ -175,7 +163,7 @@ ClientRequest.prototype._onFinish = function () {
|
||||
|
||||
// Can't set responseType on really old browsers
|
||||
if ('responseType' in xhr)
|
||||
xhr.responseType = self._mode.split(':')[0]
|
||||
xhr.responseType = self._mode
|
||||
|
||||
if ('withCredentials' in xhr)
|
||||
xhr.withCredentials = !!opts.withCredentials
|
||||
@@ -323,6 +311,5 @@ var unsafeHeaders = [
|
||||
'trailer',
|
||||
'transfer-encoding',
|
||||
'upgrade',
|
||||
'user-agent',
|
||||
'via'
|
||||
]
|
||||
|
||||
+7
-24
@@ -46,7 +46,7 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, f
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (self._destroyed) {
|
||||
reject()
|
||||
} else if(self.push(new Buffer(chunk))) {
|
||||
} else if(self.push(Buffer.from(chunk))) {
|
||||
resolve()
|
||||
} else {
|
||||
self._resumeFetch = resolve
|
||||
@@ -84,7 +84,7 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, f
|
||||
self.push(null)
|
||||
return
|
||||
}
|
||||
self.push(new Buffer(result.value))
|
||||
self.push(Buffer.from(result.value))
|
||||
read()
|
||||
}).catch(function (err) {
|
||||
global.clearTimeout(fetchTimer)
|
||||
@@ -153,29 +153,12 @@ IncomingMessage.prototype._onXHRProgress = function () {
|
||||
|
||||
var response = null
|
||||
switch (self._mode) {
|
||||
case 'text:vbarray': // For IE9
|
||||
if (xhr.readyState !== rStates.DONE)
|
||||
break
|
||||
try {
|
||||
// This fails in IE8
|
||||
response = new global.VBArray(xhr.responseBody).toArray()
|
||||
} catch (e) {}
|
||||
if (response !== null) {
|
||||
self.push(new Buffer(response))
|
||||
break
|
||||
}
|
||||
// Falls through in IE8
|
||||
case 'text':
|
||||
try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
|
||||
response = xhr.responseText
|
||||
} catch (e) {
|
||||
self._mode = 'text:vbarray'
|
||||
break
|
||||
}
|
||||
response = xhr.responseText
|
||||
if (response.length > self._pos) {
|
||||
var newData = response.substr(self._pos)
|
||||
if (self._charset === 'x-user-defined') {
|
||||
var buffer = new Buffer(newData.length)
|
||||
var buffer = Buffer.alloc(newData.length)
|
||||
for (var i = 0; i < newData.length; i++)
|
||||
buffer[i] = newData.charCodeAt(i) & 0xff
|
||||
|
||||
@@ -190,13 +173,13 @@ IncomingMessage.prototype._onXHRProgress = function () {
|
||||
if (xhr.readyState !== rStates.DONE || !xhr.response)
|
||||
break
|
||||
response = xhr.response
|
||||
self.push(new Buffer(new Uint8Array(response)))
|
||||
self.push(Buffer.from(new Uint8Array(response)))
|
||||
break
|
||||
case 'moz-chunked-arraybuffer': // take whole
|
||||
response = xhr.response
|
||||
if (xhr.readyState !== rStates.LOADING || !response)
|
||||
break
|
||||
self.push(new Buffer(new Uint8Array(response)))
|
||||
self.push(Buffer.from(new Uint8Array(response)))
|
||||
break
|
||||
case 'ms-stream':
|
||||
response = xhr.response
|
||||
@@ -205,7 +188,7 @@ IncomingMessage.prototype._onXHRProgress = function () {
|
||||
var reader = new global.MSStreamReader()
|
||||
reader.onprogress = function () {
|
||||
if (reader.result.byteLength > self._pos) {
|
||||
self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
|
||||
self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos))))
|
||||
self._pos = reader.result.byteLength
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+3595
-3546
File diff suppressed because it is too large
Load Diff
+5
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stream-http",
|
||||
"version": "2.8.2",
|
||||
"version": "3.0.0",
|
||||
"description": "Streaming http in the browser",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -29,14 +29,13 @@
|
||||
"dependencies": {
|
||||
"builtin-status-codes": "^3.0.0",
|
||||
"inherits": "^2.0.1",
|
||||
"readable-stream": "^2.3.6",
|
||||
"to-arraybuffer": "^1.0.0",
|
||||
"readable-stream": "^3.0.6",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"airtap": "^0.0.5",
|
||||
"basic-auth": "^2.0.0",
|
||||
"brfs": "^1.6.1",
|
||||
"airtap": "^0.1.0",
|
||||
"basic-auth": "^2.0.1",
|
||||
"brfs": "^2.0.1",
|
||||
"cookie-parser": "^1.4.3",
|
||||
"express": "^4.16.3",
|
||||
"tape": "^4.9.0",
|
||||
|
||||
@@ -5,18 +5,7 @@ var UAParser = require('ua-parser-js')
|
||||
|
||||
var http = require('../..')
|
||||
|
||||
var browser = (new UAParser()).setUA(navigator.userAgent).getBrowser()
|
||||
var browserName = browser.name
|
||||
var browserVersion = browser.major
|
||||
// Binary streaming doesn't work in IE10 or below
|
||||
var skipStreamingCheck = (browserName === 'IE' && browserVersion <= 10)
|
||||
|
||||
// Binary data gets corrupted in IE8 or below
|
||||
var skipVerification = (browserName === 'IE' && browserVersion <= 8)
|
||||
|
||||
// IE8 tends to throw up modal dialogs complaining about scripts running too long
|
||||
// Since streaming doesn't actually work there anyway, just use one copy
|
||||
var COPIES = skipVerification ? 1 : 20
|
||||
var COPIES = 20
|
||||
var MIN_PIECES = 2
|
||||
|
||||
var referenceOnce = fs.readFileSync(__dirname + '/../server/static/browserify.png')
|
||||
@@ -32,15 +21,8 @@ test('binary streaming', function (t) {
|
||||
}, function (res) {
|
||||
var buffers = []
|
||||
res.on('end', function () {
|
||||
if (skipVerification)
|
||||
t.skip('binary data not preserved on IE <= 8')
|
||||
else
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
|
||||
|
||||
if (skipStreamingCheck)
|
||||
t.skip('streaming not available on IE <= 8')
|
||||
else
|
||||
t.ok(buffers.length >= MIN_PIECES, 'received in multiple parts')
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
|
||||
t.ok(buffers.length >= MIN_PIECES, 'received in multiple parts')
|
||||
t.end()
|
||||
})
|
||||
|
||||
@@ -57,10 +39,7 @@ test('large binary request without streaming', function (t) {
|
||||
}, function (res) {
|
||||
var buffers = []
|
||||
res.on('end', function () {
|
||||
if (skipVerification)
|
||||
t.skip('binary data not preserved on IE <= 8')
|
||||
else
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
+1
-10
@@ -5,12 +5,6 @@ var UAParser = require('ua-parser-js')
|
||||
|
||||
var http = require('../..')
|
||||
|
||||
var browser = (new UAParser()).setUA(navigator.userAgent).getBrowser()
|
||||
var browserName = browser.name
|
||||
var browserVersion = browser.major
|
||||
// Binary data gets corrupted in IE8 or below
|
||||
var skipVerification = (browserName === 'IE' && browserVersion <= 8)
|
||||
|
||||
var reference = fs.readFileSync(__dirname + '/../server/static/browserify.png')
|
||||
|
||||
test('binary download', function (t) {
|
||||
@@ -18,10 +12,7 @@ test('binary download', function (t) {
|
||||
var buffers = []
|
||||
|
||||
res.on('end', function () {
|
||||
if (skipVerification)
|
||||
t.skip('binary data not preserved on IE <= 8')
|
||||
else
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
@@ -5,15 +5,6 @@ var UAParser = require('ua-parser-js')
|
||||
|
||||
var http = require('../..')
|
||||
|
||||
var browser = (new UAParser()).setUA(navigator.userAgent).getBrowser()
|
||||
var browserName = browser.name
|
||||
var browserVersion = browser.major
|
||||
// Binary request bodies don't work in a bunch of browsers
|
||||
var skipVerification = ((browserName === 'IE' && browserVersion <= 10) ||
|
||||
(browserName === 'Safari' && browserVersion <= 5) ||
|
||||
(browserName === 'WebKit' && browserVersion <= 534) || // Old mobile safari
|
||||
(browserName === 'Android Browser' && browserVersion <= 4))
|
||||
|
||||
var reference = fs.readFileSync(__dirname + '/../server/static/browserify.png')
|
||||
|
||||
test('post binary', function (t) {
|
||||
@@ -24,10 +15,7 @@ test('post binary', function (t) {
|
||||
var buffers = []
|
||||
|
||||
res.on('end', function () {
|
||||
if (skipVerification)
|
||||
t.skip('binary data not preserved on this browser')
|
||||
else
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'echoed contents match')
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'echoed contents match')
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
@@ -28,10 +28,7 @@ test('text streaming', function (t) {
|
||||
var buffers = []
|
||||
|
||||
res.on('end', function () {
|
||||
if (skipStreamingCheck)
|
||||
t.skip('streaming not available on IE <= 8')
|
||||
else
|
||||
t.ok(buffers.length >= MIN_PIECES, 'received in multiple parts')
|
||||
t.ok(buffers.length >= MIN_PIECES, 'received in multiple parts')
|
||||
t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
|
||||
t.end()
|
||||
})
|
||||
|
||||
@@ -15,7 +15,6 @@ var skipResponseUrl = ((browserName === 'IE') ||
|
||||
(browserName === 'Chrome' && browserVersion <= 36) ||
|
||||
(browserName === 'Firefox' && browserVersion <= 31) ||
|
||||
((browserName === 'Safari' || browserName === 'Mobile Safari') && browserVersion <= 8) ||
|
||||
(browserName === 'WebKit') || // Old mobile safari
|
||||
(browserName === 'Android Browser' && browserVersion <= 4))
|
||||
|
||||
var reference = fs.readFileSync(__dirname + '/../server/static/basic.txt')
|
||||
|
||||
@@ -4,20 +4,10 @@ var UAParser = require('ua-parser-js')
|
||||
var url = require('url')
|
||||
var work = require('webworkify')
|
||||
|
||||
var browser = (new UAParser()).setUA(navigator.userAgent).getBrowser()
|
||||
var browserName = browser.name
|
||||
var browserVersion = browser.major
|
||||
// Skip browsers with poor or nonexistant WebWorker support
|
||||
var skip = ((browserName === 'IE' && browserVersion <= 10) ||
|
||||
(browserName === 'Safari' && browserVersion <= 5) ||
|
||||
(browserName === 'WebKit' && browserVersion <= 534) || // Old mobile safari
|
||||
(browserName === 'Android Browser' && browserVersion <= 4))
|
||||
|
||||
var reference = fs.readFileSync(__dirname + '/../server/static/browserify.png')
|
||||
|
||||
test('binary download in WebWorker', {
|
||||
skip: skip
|
||||
}, function (t) {
|
||||
// Temporarily disabled due to https://github.com/browserify/webworkify/issues/41
|
||||
test.skip('binary download in WebWorker', function (t) {
|
||||
// We have to use a global url, since webworkify puts the worker in a Blob,
|
||||
// which doesn't have a proper location
|
||||
var testUrl = url.resolve(global.location.href, '/browserify.png')
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../ie8-polyfill.js
|
||||
Reference in New Issue
Block a user