Skip to content

Commit bf7f080

Browse files
Browser test passing
1 parent aba8014 commit bf7f080

14 files changed

+57
-70
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
node_modules/
1+
node_modules
22
.DS_Store
3+
4+
*.log

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
language: node_js
22
node_js:
3-
- '4'
4-
- '5'
3+
- "0.10"
4+
- 4
5+
- 5
56
- stable
67

78
before_install:
89
- "export DISPLAY=:99.0"
910
- "sh -e /etc/init.d/xvfb start"
1011

12+
addons:
13+
firefox: "latest"
14+
1115
script:
1216
- npm run lint
1317
- npm test

karma.conf.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module.exports = function (karma) {
99
debug: true,
1010
transform: ['brfs']
1111
},
12-
browsers: process.env.TRAVIS ? ['Firefox', 'PhantomJS'] : ['Chrome'/*, 'PhantomJS'*/]
12+
reporters: ['mocha-own'],
13+
mochaOwnReporter: {
14+
reporter: 'spec'
15+
},
16+
browsers: process.env.TRAVIS ? ['Firefox', 'PhantomJS'] : ['Chrome', 'PhantomJS']
1317
})
1418
}

npm-debug.log

Lines changed: 0 additions & 48 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"karma-chrome-launcher": "^0.2.3",
2121
"karma-firefox-launcher": "^0.1.7",
2222
"karma-mocha": "^0.2.2",
23+
"karma-mocha-own-reporter": "^1.1.2",
2324
"karma-phantomjs-launcher": "^1.0.0",
2425
"mocha": "^2.4.5",
2526
"phantomjs-prebuilt": "^2.1.7",

src/binding.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Zlib.prototype.init = function (windowBits, level, memLevel, strategy, dictionar
4242
this.level = level
4343
this.memLevel = memLevel
4444
this.strategy = strategy
45-
// dictionary not supported.
45+
this.dictionary = dictionary
4646

4747
if (this.mode === exports.GZIP || this.mode === exports.GUNZIP) {
4848
this.windowBits += 16
@@ -193,7 +193,7 @@ Zlib.prototype._write = function (flush, input, in_off, in_len, out, out_off, ou
193193
}
194194

195195
if (status !== exports.Z_STREAM_END && status !== exports.Z_OK) {
196-
this._error(status)
196+
this._error(status, flush)
197197
}
198198

199199
this.write_in_progress = false
@@ -235,8 +235,33 @@ Zlib.prototype.reset = function () {
235235
}
236236
}
237237

238-
Zlib.prototype._error = function (status) {
239-
this.onerror(msg[status] + ': ' + this.strm.msg, status)
238+
Zlib.prototype._error = function (status, flush) {
239+
var errMsg
240+
241+
switch (status) {
242+
case exports.Z_OK:
243+
case exports.Z_BUF_ERROR:
244+
if (this.strm.avail_out !== 0 && flush === exports.Z_FINISH) {
245+
errMsg = 'unexpected end of file'
246+
} else {
247+
errMsg = msg[status]
248+
}
249+
break
250+
case exports.Z_STREAM_END:
251+
// normal statuses, not fatal
252+
break
253+
case exports.Z_NEED_DICT:
254+
if (!this.dictionary) {
255+
errMsg = 'Missing dictionary'
256+
} else {
257+
errMsg = 'Bad dictionary'
258+
}
259+
break
260+
default:
261+
errMsg = status[msg]
262+
}
263+
264+
this.onerror(errMsg, status)
240265

241266
this.write_in_progress = false
242267
if (this.pending_close) {

test/test-zlib-close-after-write.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
var zlib = require('../')
55

6-
describe('zlib', function () {
7-
it('closes after write', function (done) {
6+
describe('zlib - close after write', function () {
7+
it('works', function (done) {
88
zlib.gzip('hello', function (err, out) {
99
if (err) throw err
1010
var unzip = zlib.createGunzip()

test/test-zlib-dictionary-fail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var assert = require('assert')
55
var common = require('./common')
66
var zlib = require('../')
77

8-
describe.skip('zlib - dictionary fails', function () {
8+
describe('zlib - dictionary fails', function () {
99
it('should fail on missing dictionary', function (done) {
1010
// Should raise an error, not trigger an assertion in src/node_zlib.cc
1111
var stream = zlib.createInflate()

test/test-zlib-flush.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
var common = require('./common')
54
var assert = require('assert')
65
var zlib = require('../')
76
var path = require('path')
87
var fs = require('fs')
98

109
describe.skip('zlib - flush', function () {
1110
it('works', function (done) {
12-
var file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg'))
11+
var file = fs.readFileSync(path.join(__dirname, 'fixtures', 'person.jpg'))
1312
var chunkSize = 16
1413
var opts = { level: 0 }
1514
var deflater = zlib.createDeflate(opts)

test/test-zlib-from-concatenated-gzip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe.skip('zlib - from concatenated gzip', function () {
1515

1616
assert.equal(zlib.gunzipSync(data).toString(), 'abcdef')
1717

18-
zlib.gunzip(data, common.mustCall((err, result) => {
18+
zlib.gunzip(data, common.mustCall(function (err, result) {
1919
assert.ifError(err)
2020
assert.equal(result, 'abcdef', 'result should match original string')
2121
done()

0 commit comments

Comments
 (0)