1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Convert var to const/let in the test/unit folder

This has been done automatically using ESLint's `--fix` argument.
This commit is contained in:
Tim van der Meij 2020-10-25 15:40:51 +01:00
parent 314ac21842
commit 3e2bfb5819
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
17 changed files with 630 additions and 604 deletions

View file

@ -41,8 +41,8 @@ function withZlib(isZlibRequired, callback) {
return callback();
}
var zlib = __non_webpack_require__("zlib");
var deflateSync = zlib.deflateSync;
const zlib = __non_webpack_require__("zlib");
const deflateSync = zlib.deflateSync;
zlib.deflateSync = disabledDeflateSync;
function disabledDeflateSync() {
throw new Error("zlib.deflateSync is explicitly disabled for testing.");
@ -52,14 +52,14 @@ function withZlib(isZlibRequired, callback) {
zlib.deflateSync = deflateSync;
}
}
var promise = callback();
const promise = callback();
promise.then(restoreDeflateSync, restoreDeflateSync);
return promise;
}
describe("SVGGraphics", function () {
var loadingTask;
var page;
let loadingTask;
let page;
beforeAll(function (done) {
loadingTask = getDocument(buildGetDocumentParams("xobject-image.pdf"));
loadingTask.promise.then(function (doc) {
@ -75,30 +75,30 @@ describe("SVGGraphics", function () {
describe("paintImageXObject", function () {
function getSVGImage() {
var svgGfx;
let svgGfx;
return page
.getOperatorList()
.then(function (opList) {
var forceDataSchema = true;
const forceDataSchema = true;
svgGfx = new SVGGraphics(page.commonObjs, page.objs, forceDataSchema);
return svgGfx.loadDependencies(opList);
})
.then(function () {
var svgImg;
let svgImg;
// A mock to steal the svg:image element from paintInlineImageXObject.
var elementContainer = {
const elementContainer = {
appendChild(element) {
svgImg = element;
},
};
// This points to the XObject image in xobject-image.pdf.
var xobjectObjId = "img_p0_1";
const xobjectObjId = "img_p0_1";
if (isNodeJS) {
setStubs(global);
}
try {
var imgData = svgGfx.objs.get(xobjectObjId);
const imgData = svgGfx.objs.get(xobjectObjId);
svgGfx.paintInlineImageXObject(imgData, elementContainer);
} finally {
if (isNodeJS) {
@ -133,7 +133,7 @@ describe("SVGGraphics", function () {
expect(svgImg.nodeName).toBe("svg:image");
expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
var imgUrl = svgImg.getAttributeNS(XLINK_NS, "href");
const imgUrl = svgImg.getAttributeNS(XLINK_NS, "href");
// forceDataSchema = true, so the generated URL should be a data:-URL.
expect(imgUrl).toMatch(/^data:image\/png;base64,/);
// Test whether the generated image has a reasonable file size.
@ -151,7 +151,7 @@ describe("SVGGraphics", function () {
expect(svgImg.nodeName).toBe("svg:image");
expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
var imgUrl = svgImg.getAttributeNS(XLINK_NS, "href");
const imgUrl = svgImg.getAttributeNS(XLINK_NS, "href");
expect(imgUrl).toMatch(/^data:image\/png;base64,/);
// The size of our naively generated PNG file is excessive :(
expect(imgUrl.length).toBe(80246);