-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add browser tests and use saucelabs to test them.
This also finds and fixes errors related to string encoding and some compatablity issues which allow it to work as far back as IE 9 (probably IE 8 with an ES5 shm).
- Loading branch information
1 parent
53b588e
commit b681059
Showing
51 changed files
with
3,938 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,38 @@ | ||
language: node_js | ||
before_install: | ||
- npm install -g npm | ||
node_js: | ||
- "0.8" | ||
- "0.10" | ||
- "0.11" | ||
- "0.12" | ||
- "iojs" | ||
notifications: | ||
email: false | ||
matrix: | ||
include: | ||
- node_js: '0.8' | ||
env: TASK=test | ||
- node_js: '0.10' | ||
env: TASK=test | ||
- node_js: '0.11' | ||
env: TASK=test | ||
- node_js: '0.12' | ||
env: TASK=test | ||
- node_js: 'iojs' | ||
env: TASK=test | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest" | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=ie BROWSER_VERSION="9..latest" | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="39..beta" | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="34..beta" | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest" | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest" | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest" | ||
- node_js: 'iojs' | ||
env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest" | ||
script: "npm run $TASK" | ||
env: | ||
global: | ||
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc= | ||
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ui: tape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,12 +143,15 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() { | |
return out; | ||
}; | ||
|
||
(function (){try { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
calvinmetcalf
Author
Contributor
|
||
Object.defineProperty(WritableState.prototype, 'buffer', { | ||
get: require('util-deprecate')(function() { | ||
return this.getBuffer(); | ||
}, '_writableState.buffer is deprecated. Use ' + | ||
'_writableState.getBuffer() instead.') | ||
}); | ||
}catch(_){}}()); | ||
|
||
|
||
function Writable(options) { | ||
var Duplex = require('./_stream_duplex'); | ||
|
@@ -217,7 +220,7 @@ Writable.prototype.write = function(chunk, encoding, cb) { | |
encoding = null; | ||
} | ||
|
||
if (chunk instanceof Buffer) | ||
if (Buffer.isBuffer(chunk)) | ||
encoding = 'buffer'; | ||
else if (!encoding) | ||
encoding = state.defaultEncoding; | ||
|
@@ -282,7 +285,7 @@ function decodeChunk(state, chunk, encoding) { | |
function writeOrBuffer(stream, state, chunk, encoding, cb) { | ||
chunk = decodeChunk(state, chunk, encoding); | ||
|
||
if (chunk instanceof Buffer) | ||
if (Buffer.isBuffer(chunk)) | ||
encoding = 'buffer'; | ||
var len = state.objectMode ? 1 : chunk.length; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
if (!global.console) { | ||
global.console = {}; | ||
} | ||
if (!global.console.log) { | ||
global.console.log = function () {}; | ||
} | ||
if (!global.console.error) { | ||
global.console.error = global.console.log; | ||
} | ||
if (!global.console.info) { | ||
global.console.info = global.console.log; | ||
} | ||
var test = require('tape'); | ||
|
||
test('streams', function (t) { | ||
require('./browser/test-stream-big-packet')(t); | ||
require('./browser/test-stream-big-push')(t); | ||
require('./browser/test-stream-duplex')(t); | ||
require('./browser/test-stream-end-paused')(t); | ||
require('./browser/test-stream-ispaused')(t); | ||
require('./browser/test-stream-pipe-after-end')(t); | ||
require('./browser/test-stream-pipe-cleanup')(t); | ||
require('./browser/test-stream-pipe-error-handling')(t); | ||
require('./browser/test-stream-pipe-event')(t); | ||
require('./browser/test-stream-push-order')(t); | ||
require('./browser/test-stream-push-strings')(t); | ||
require('./browser/test-stream-readable-constructor-set-methods')(t); | ||
require('./browser/test-stream-readable-event')(t); | ||
require('./browser/test-stream-transform-constructor-set-methods')(t); | ||
require('./browser/test-stream-transform-objectmode-falsey-value')(t); | ||
require('./browser/test-stream-transform-split-objectmode')(t); | ||
require('./browser/test-stream-unshift-empty-chunk')(t); | ||
require('./browser/test-stream-unshift-read-race')(t); | ||
require('./browser/test-stream-writable-change-default-encoding')(t); | ||
require('./browser/test-stream-writable-constructor-set-methods')(t); | ||
require('./browser/test-stream-writable-decoded-encoding')(t); | ||
require('./browser/test-stream-writev')(t); | ||
}); | ||
|
||
test('streams 2', function (t) { | ||
require('./browser/test-stream2-base64-single-char-read-end')(t); | ||
require('./browser/test-stream2-compatibility')(t); | ||
require('./browser/test-stream2-large-read-stall')(t); | ||
require('./browser/test-stream2-objects')(t); | ||
require('./browser/test-stream2-pipe-error-handling')(t); | ||
require('./browser/test-stream2-pipe-error-once-listener')(t); | ||
require('./browser/test-stream2-push')(t); | ||
require('./browser/test-stream2-readable-empty-buffer-no-eof')(t); | ||
require('./browser/test-stream2-readable-from-list')(t); | ||
require('./browser/test-stream2-transform')(t); | ||
require('./browser/test-stream2-set-encoding')(t); | ||
require('./browser/test-stream2-readable-legacy-drain')(t); | ||
require('./browser/test-stream2-readable-wrap-empty')(t); | ||
require('./browser/test-stream2-readable-non-empty-end')(t); | ||
require('./browser/test-stream2-readable-wrap')(t); | ||
require('./browser/test-stream2-unpipe-drain')(t); | ||
require('./browser/test-stream2-writable')(t); | ||
}); | ||
test('streams 3', function (t) { | ||
require('./browser/test-stream3-pause-then-read')(t); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var inherits = require('inherits'); | ||
var stream = require('../../'); | ||
|
||
module.exports = function (t) { | ||
t.test('big packet', function (t) { | ||
t.plan(3); | ||
var passed = false; | ||
|
||
function PassThrough() { | ||
stream.Transform.call(this); | ||
}; | ||
inherits(PassThrough, stream.Transform); | ||
PassThrough.prototype._transform = function(chunk, encoding, done) { | ||
this.push(chunk); | ||
done(); | ||
}; | ||
|
||
function TestStream() { | ||
stream.Transform.call(this); | ||
}; | ||
inherits(TestStream, stream.Transform); | ||
TestStream.prototype._transform = function(chunk, encoding, done) { | ||
if (!passed) { | ||
// Char 'a' only exists in the last write | ||
passed = indexOf(chunk.toString(), 'a') >= 0; | ||
} | ||
if (passed) { | ||
t.ok(passed); | ||
} | ||
done(); | ||
}; | ||
|
||
var s1 = new PassThrough(); | ||
var s2 = new PassThrough(); | ||
var s3 = new TestStream(); | ||
s1.pipe(s3); | ||
// Don't let s2 auto close which may close s3 | ||
s2.pipe(s3, {end: false}); | ||
|
||
// We must write a buffer larger than highWaterMark | ||
var big = new Buffer(s1._writableState.highWaterMark + 1); | ||
big.fill('x'); | ||
|
||
// Since big is larger than highWaterMark, it will be buffered internally. | ||
t.ok(!s1.write(big)); | ||
// 'tiny' is small enough to pass through internal buffer. | ||
t.ok(s2.write('tiny')); | ||
|
||
// Write some small data in next IO loop, which will never be written to s3 | ||
// Because 'drain' event is not emitted from s1 and s1 is still paused | ||
setImmediate(s1.write.bind(s1), 'later'); | ||
|
||
function indexOf (xs, x) { | ||
for (var i = 0, l = xs.length; i < l; i++) { | ||
if (xs[i] === x) return i; | ||
} | ||
return -1; | ||
} | ||
}); | ||
} |
Oops, something went wrong.
thank you for adding this-- streams were blowing up in sandboxed iframes b/c of a security error
TooTallNate/util-deprecate#2