diff --git a/.eslintrc b/.eslintrc index aca4fe1ac..46d12b2ca 100644 --- a/.eslintrc +++ b/.eslintrc @@ -84,6 +84,10 @@ "no-shadow-restricted-names": "error", "no-undef-init": "error", "no-undef": ["error", { "typeof": true, }], + "no-unused-vars": ["error", { + "vars": "local", + "args": "none", + }], // Stylistic Issues "array-bracket-spacing": ["error", "never"], diff --git a/external/importL10n/locales.js b/external/importL10n/locales.js index 1290101cd..5a507aba9 100644 --- a/external/importL10n/locales.js +++ b/external/importL10n/locales.js @@ -62,7 +62,8 @@ function downloadLanguageFiles(root, langCode, callback) { files.forEach(function(fileName) { var outputPath = path.join(outputDir, fileName); var url = MOZ_AURORA_ROOT + langCode + MOZ_AURORA_PDFJS_DIR + fileName; - var request = https.get(url, function(response) { + + https.get(url, function(response) { var content = ''; response.setEncoding('utf8'); response.on('data', function(chunk) { diff --git a/src/core/annotation.js b/src/core/annotation.js index c198374f3..6eeb5d97f 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -38,7 +38,6 @@ var AnnotationFlag = sharedUtil.AnnotationFlag; var AnnotationType = sharedUtil.AnnotationType; var OPS = sharedUtil.OPS; var Util = sharedUtil.Util; -var isString = sharedUtil.isString; var isArray = sharedUtil.isArray; var isInt = sharedUtil.isInt; var stringToBytes = sharedUtil.stringToBytes; diff --git a/src/core/cff_parser.js b/src/core/cff_parser.js index f1e8c4249..22c109257 100644 --- a/src/core/cff_parser.js +++ b/src/core/cff_parser.js @@ -785,7 +785,6 @@ var CFFParser = (function CFFParserClosure() { var encoding = Object.create(null); var bytes = this.bytes; var predefined = false; - var hasSupplement = false; var format, i, ii; var raw = null; @@ -836,7 +835,7 @@ var CFFParser = (function CFFParserClosure() { break; } var dataEnd = pos; - if (format & 0x80) { + if (format & 0x80) { // hasSupplement // The font sanitizer does not support CFF encoding with a // supplement, since the encoding is not really used to map // between gid to glyph, let's overwrite what is declared in @@ -844,7 +843,6 @@ var CFFParser = (function CFFParserClosure() { // StandardEncoding, that's a lie but that's ok. bytes[dataStart] &= 0x7f; readSupplement(); - hasSupplement = true; } raw = bytes.subarray(dataStart, dataEnd); } diff --git a/src/core/crypto.js b/src/core/crypto.js index 5a24e5b64..0ff5aea13 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -1084,30 +1084,6 @@ var AES128Cipher = (function AES128CipherClosure() { })(); var AES256Cipher = (function AES256CipherClosure() { - var rcon = new Uint8Array([ - 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, - 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, - 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, - 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, - 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, - 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, - 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, - 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, - 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, - 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, - 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, - 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, - 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, - 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, - 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, - 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, - 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, - 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, - 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, - 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, - 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, - 0x74, 0xe8, 0xcb, 0x8d]); - var s = new Uint8Array([ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 31155e74a..089a574ec 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1296,22 +1296,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var width = 0; var height = 0; var glyphs = font.charsToGlyphs(chars); - var defaultVMetrics = font.defaultVMetrics; for (var i = 0; i < glyphs.length; i++) { var glyph = glyphs[i]; - var vMetricX = null; - var vMetricY = null; var glyphWidth = null; - if (font.vertical) { - if (glyph.vmetric) { - glyphWidth = glyph.vmetric[0]; - vMetricX = glyph.vmetric[1]; - vMetricY = glyph.vmetric[2]; - } else { - glyphWidth = glyph.width; - vMetricX = glyph.width * 0.5; - vMetricY = defaultVMetrics[2]; - } + if (font.vertical && glyph.vmetric) { + glyphWidth = glyph.vmetric[0]; } else { glyphWidth = glyph.width; } @@ -1323,18 +1312,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { } glyphUnicode = reverseIfRtl(glyphUnicode); - // The following will calculate the x and y of the individual glyphs. - // if (font.vertical) { - // tsm[4] -= vMetricX * Math.abs(textState.fontSize) * - // textState.fontMatrix[0]; - // tsm[5] -= vMetricY * textState.fontSize * - // textState.fontMatrix[0]; - // } - // var trm = Util.transform(textState.textMatrix, tsm); - // var pt = Util.applyTransform([trm[4], trm[5]], textState.ctm); - // var x = pt[0]; - // var y = pt[1]; - var charSpacing = textState.charSpacing; if (glyph.isSpace) { var wordSpacing = textState.wordSpacing; diff --git a/src/core/font_renderer.js b/src/core/font_renderer.js index 67ec09a7f..8529bea4d 100644 --- a/src/core/font_renderer.js +++ b/src/core/font_renderer.js @@ -53,9 +53,9 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { var offset = (getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16)); var format = getUshort(data, start + offset); - var length, ranges, p, i; + var ranges, p, i; if (format === 4) { - length = getUshort(data, start + offset + 2); + getUshort(data, start + offset + 2); // length var segCount = getUshort(data, start + offset + 6) >> 1; p = start + offset + 14; ranges = []; @@ -82,7 +82,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { } return ranges; } else if (format === 12) { - length = getLong(data, start + offset + 4); + getLong(data, start + offset + 4); // length var groups = getLong(data, start + offset + 12); p = start + offset + 16; ranges = []; diff --git a/src/core/fonts.js b/src/core/fonts.js index 796d1f38a..7dd108433 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -594,9 +594,6 @@ var Font = (function FontClosure() { this.glyphCache = Object.create(null); - var names = name.split('+'); - names = names.length > 1 ? names[1] : names[0]; - names = names.split(/[-,_]/g)[0]; this.isSerifFont = !!(properties.flags & FontFlags.Serif); this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic); this.isMonospace = !!(properties.flags & FontFlags.FixedPitch); @@ -1409,7 +1406,7 @@ var Font = (function FontClosure() { var start = (font.start ? font.start : 0) + cmap.offset; font.pos = start; - var version = font.getUint16(); + font.getUint16(); // version var numTables = font.getUint16(); var potentialTable; @@ -1471,8 +1468,8 @@ var Font = (function FontClosure() { } var format = font.getUint16(); - var length = font.getUint16(); - var language = font.getUint16(); + font.getUint16(); // length + font.getUint16(); // language var hasShortCmap = false; var mappings = []; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 0ee2ee041..cc9446dc2 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -432,14 +432,12 @@ var Jbig2Image = (function Jbig2ImageClosure() { var deltaHeight = decodeInteger(contextCache, 'IADH', decoder); // 6.5.6 currentHeight += deltaHeight; var currentWidth = 0; - var totalWidth = 0; while (true) { var deltaWidth = decodeInteger(contextCache, 'IADW', decoder); // 6.5.7 if (deltaWidth === null) { break; // OOB } currentWidth += deltaWidth; - totalWidth += currentWidth; var bitmap; if (refinement) { // 6.5.8.2 Refinement/aggregate-coded symbol bitmap @@ -889,7 +887,7 @@ var Jbig2Image = (function Jbig2ImageClosure() { delete pageInfo.height; } var pageSegmentFlags = data[position + 16]; - var pageStripingInformation = readUint16(data, position + 17); + readUint16(data, position + 17); // pageStripingInformation pageInfo.lossless = !!(pageSegmentFlags & 1); pageInfo.refinement = !!(pageSegmentFlags & 2); pageInfo.defaultPixelValue = (pageSegmentFlags >> 2) & 1; @@ -923,7 +921,7 @@ var Jbig2Image = (function Jbig2ImageClosure() { } } - function parseJbig2(data, start, end) { + function parseJbig2(data, start, end) { // eslint-disable-line no-unused-vars var position = start; if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || @@ -939,7 +937,7 @@ var Jbig2Image = (function Jbig2ImageClosure() { header.numberOfPages = readUint32(data, position); position += 4; } - var segments = readSegments(header, data, position, end); + readSegments(header, data, position, end); // segments error('Not implemented'); // processSegments(segments, new SimpleSegmentVisitor()); } diff --git a/src/core/jpg.js b/src/core/jpg.js index 342c36836..ac5397ac5 100644 --- a/src/core/jpg.js +++ b/src/core/jpg.js @@ -790,7 +790,7 @@ var JpegImage = (function JpegImageClosure() { break; case 0xFFDA: // SOS (Start of Scan) - var scanLength = readUint16(); + readUint16(); // scanLength var selectorsCount = data[offset++]; var components = [], component; for (i = 0; i < selectorsCount; i++) { diff --git a/src/core/stream.js b/src/core/stream.js index a7da21c1e..45af86362 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -38,7 +38,6 @@ var isInt = sharedUtil.isInt; var isArray = sharedUtil.isArray; var createObjectURL = sharedUtil.createObjectURL; var shadow = sharedUtil.shadow; -var warn = sharedUtil.warn; var isSpace = sharedUtil.isSpace; var Dict = corePrimitives.Dict; var isDict = corePrimitives.isDict; diff --git a/src/core/type1_parser.js b/src/core/type1_parser.js index 935faf552..48b206fe7 100644 --- a/src/core/type1_parser.js +++ b/src/core/type1_parser.js @@ -251,7 +251,7 @@ var Type1CharString = (function Type1CharStringClosure() { // first part of the charstring and then use rmoveto with // (dx, dy). The height argument will not be used for vmtx and // vhea tables reconstruction -- ignoring it. - var wy = this.stack.pop(); + this.stack.pop(); // wy wx = this.stack.pop(); var sby = this.stack.pop(); sbx = this.stack.pop(); @@ -579,7 +579,7 @@ var Type1Parser = (function Type1ParserClosure() { } break; case 'Subrs': - var num = this.readInt(); + this.readInt(); // num this.getToken(); // read in 'array' while ((token = this.getToken()) === 'dup') { var index = this.readInt(); diff --git a/src/core/worker.js b/src/core/worker.js index 16cd628cd..12eb5267f 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -36,7 +36,6 @@ var MessageHandler = sharedUtil.MessageHandler; var MissingPDFException = sharedUtil.MissingPDFException; var UnexpectedResponseException = sharedUtil.UnexpectedResponseException; var PasswordException = sharedUtil.PasswordException; -var PasswordResponses = sharedUtil.PasswordResponses; var UnknownErrorException = sharedUtil.UnknownErrorException; var XRefParseException = sharedUtil.XRefParseException; var arrayByteLength = sharedUtil.arrayByteLength; @@ -448,7 +447,7 @@ var WorkerMessageHandler = { var responseExists = 'response' in xhr; // check if the property is actually implemented try { - var dummy = xhr.responseType; + xhr.responseType; // eslint-disable-line no-unused-expressions } catch (e) { responseExists = false; } diff --git a/src/display/api.js b/src/display/api.js index 287c1e7cb..5c0649351 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -39,7 +39,6 @@ var InvalidPDFException = sharedUtil.InvalidPDFException; var MessageHandler = sharedUtil.MessageHandler; var MissingPDFException = sharedUtil.MissingPDFException; var PageViewport = sharedUtil.PageViewport; -var PasswordResponses = sharedUtil.PasswordResponses; var PasswordException = sharedUtil.PasswordException; var StatTimer = sharedUtil.StatTimer; var UnexpectedResponseException = sharedUtil.UnexpectedResponseException; diff --git a/src/pdf.js b/src/pdf.js index e70d6f0de..96751da19 100644 --- a/src/pdf.js +++ b/src/pdf.js @@ -13,6 +13,7 @@ * limitations under the License. */ /* eslint strict: ["error", "function"] */ +/* eslint-disable no-unused-vars */ /* umdutils ignore */ (function (root, factory) { diff --git a/test/driver.js b/test/driver.js index 466cd2bed..1de42b226 100644 --- a/test/driver.js +++ b/test/driver.js @@ -673,3 +673,5 @@ var Driver = (function DriverClosure() { return Driver; })(); + +exports.Driver = Driver; diff --git a/test/font/fontutils.js b/test/font/fontutils.js index a8755d273..6cddef9ac 100644 --- a/test/font/fontutils.js +++ b/test/font/fontutils.js @@ -88,3 +88,7 @@ function verifyTtxOutput(output) { throw m[1]; } } + +exports.decodeFontData = decodeFontData; +exports.ttx = ttx; +exports.verifyTtxOutput = verifyTtxOutput; diff --git a/test/unit/cff_parser_spec.js b/test/unit/cff_parser_spec.js index 05fd76300..09f0e0855 100644 --- a/test/unit/cff_parser_spec.js +++ b/test/unit/cff_parser_spec.js @@ -189,7 +189,7 @@ describe('CFFParser', function() { it('parses a CharString endchar with 4 args w/seac enabled', function() { var parser = new CFFParser(fontData, {}, /* seacAnalysisEnabled = */ true); - var cff = parser.parse(); + parser.parse(); // cff var bytes = new Uint8Array([0, 1, // count 1, // offsetSize @@ -211,7 +211,7 @@ describe('CFFParser', function() { it('parses a CharString endchar with 4 args w/seac disabled', function() { var parser = new CFFParser(fontData, {}, /* seacAnalysisEnabled = */ false); - var cff = parser.parse(); + parser.parse(); // cff var bytes = new Uint8Array([0, 1, // count 1, // offsetSize diff --git a/test/unit/jasmine-boot.js b/test/unit/jasmine-boot.js index 0df7797e2..8914fae94 100644 --- a/test/unit/jasmine-boot.js +++ b/test/unit/jasmine-boot.js @@ -40,8 +40,6 @@ 'use strict'; -var pdfjsLibs; - function initializePDFJS(callback) { require.config({paths: {'pdfjs': '../../src', 'pdfjs-web': '../../web', 'pdfjs-test': '..'}}); diff --git a/test/unit/network_spec.js b/test/unit/network_spec.js index 8720a5c1c..9c8cae63f 100644 --- a/test/unit/network_spec.js +++ b/test/unit/network_spec.js @@ -63,7 +63,7 @@ describe('network', function() { }); }; - var readPromise = read(); + var readPromise = Promise.all([read(), promise]); readPromise.then(function (page) { expect(len).toEqual(pdf1Length); @@ -117,12 +117,13 @@ describe('network', function() { }); }; - var readPromise = read(); + var readPromise = Promise.all([read(), promise]); readPromise.then(function () { expect(len).toEqual(pdf2Length); expect(count).toBeGreaterThan(1); expect(isStreamingSupported).toEqual(true); + expect(isRangeSupported).toEqual(true); done(); }).catch(function (reason) { done.fail(reason); @@ -179,6 +180,7 @@ describe('network', function() { readPromises.then(function () { expect(result1.value).toEqual(rangeSize); expect(result2.value).toEqual(tailSize); + expect(isStreamingSupported).toEqual(false); expect(isRangeSupported).toEqual(true); expect(fullReaderCancelled).toEqual(true); done(); diff --git a/test/unit/testreporter.js b/test/unit/testreporter.js index c22a9edf3..120cd0681 100644 --- a/test/unit/testreporter.js +++ b/test/unit/testreporter.js @@ -74,3 +74,5 @@ var TestReporter = function(browser, appPath) { setTimeout(sendQuitRequest, 500); }; }; + +exports.TestReporter = TestReporter; diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 115d24899..0ea77452a 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -360,7 +360,6 @@ var PDFPageView = (function PDFPageViewClosure() { var self = this; var pdfPage = this.pdfPage; - var viewport = this.viewport; var div = this.div; // Wrap the canvas so if it has a css transform for highdpi the overflow // will be hidden in FF. @@ -519,8 +518,6 @@ var PDFPageView = (function PDFPageViewClosure() { } }; - var self = this; - var pdfPage = this.pdfPage; var viewport = this.viewport; var canvas = document.createElement('canvas'); canvas.id = 'page' + this.id; diff --git a/web/pdf_print_service.js b/web/pdf_print_service.js index d138c9663..5cf2c64df 100644 --- a/web/pdf_print_service.js +++ b/web/pdf_print_service.js @@ -85,7 +85,6 @@ layout: function () { this.throwIfInactive(); - var pdfDocument = this.pdfDocument; var body = document.querySelector('body'); body.setAttribute('data-pdfjsprinting', true);