Skip to content
8 changes: 6 additions & 2 deletions .puppeteerrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"chrome": {
"skipDownload": false
"skipDownload": true,
"version": "stable"
},
"chrome-headless-shell": {
"skipDownload": true
},
"firefox": {
"skipDownload": false,
"skipDownload": true,
"version": "nightly"
}
}
5 changes: 1 addition & 4 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,10 +1030,7 @@ function createBuildNumber(done) {
const version = config.versionPrefix + buildNumber;

exec('git log --format="%h" -n 1', function (err2, stdout2, stderr2) {
let buildCommit = "";
if (!err2) {
buildCommit = stdout2.replace("\n", "");
}
const buildCommit = !err2 ? stdout2.replace("\n", "") : "";

createStringSource(
"version.json",
Expand Down
33 changes: 17 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"eslint-plugin-perfectionist": "^5.9.0",
"eslint-plugin-prettier": "^5.5.6",
"eslint-plugin-regexp": "^3.1.0",
"eslint-plugin-unicorn": "^65.0.1",
"eslint-plugin-unicorn": "^66.0.0",
"globals": "^17.6.0",
"gulp": "^5.0.1",
"gulp-cli": "^3.1.0",
Expand Down
5 changes: 1 addition & 4 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4265,10 +4265,7 @@ class FreeTextAnnotation extends MarkupAnnotation {
totalWidth = Math.max(totalWidth, lineWidth);
}

let hscale = 1;
if (totalWidth > w) {
hscale = w / totalWidth;
}
const hscale = totalWidth > w ? w / totalWidth : 1;
let vscale = 1;
const lineHeight = LINE_FACTOR * fontSize;
const lineAscent = (LINE_FACTOR - LINE_DESCENT_FACTOR) * fontSize;
Expand Down
5 changes: 1 addition & 4 deletions src/core/default_appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,7 @@ class FakeUnicodeFont {
[w, h] = [h, w];
}

let hscale = 1;
if (maxWidth > w) {
hscale = w / maxWidth;
}
const hscale = maxWidth > w ? w / maxWidth : 1;
let vscale = 1;
const lineHeight = LINE_FACTOR * fontSize;
const lineDescent = LINE_DESCENT_FACTOR * fontSize;
Expand Down
5 changes: 1 addition & 4 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3535,10 +3535,7 @@ class PartialEvaluator {
if (includeMarkedContent) {
markedContentData.level++;

let mcid = null;
if (args[1] instanceof Dict) {
mcid = args[1].get("MCID");
}
const mcid = args[1] instanceof Dict ? args[1].get("MCID") : null;
textContent.items.push({
type: "beginMarkedContentProps",
id: Number.isInteger(mcid)
Expand Down
10 changes: 2 additions & 8 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3171,10 +3171,7 @@ class Font {
// there isn't enough room to duplicate, the glyph id is left the same. In
// this case, glyph 0 may not work correctly, but that is better than
// having the whole font fail.
let glyphZeroId = numGlyphsOut - 1;
if (!dupFirstEntry) {
glyphZeroId = 0;
}
const glyphZeroId = dupFirstEntry ? numGlyphsOut - 1 : 0;

// When `cssFontInfo` is set, the font is used to render text in the HTML
// view (e.g. with Xfa) so nothing must be moved in the private use area.
Expand Down Expand Up @@ -3248,10 +3245,7 @@ class Font {
// Type 1 fonts have a notdef inserted at the beginning, so glyph 0
// becomes glyph 1. In a CFF font glyph 0 is appended to the end of the
// char strings.
let glyphZeroId = 1;
if (font instanceof CFFFont) {
glyphZeroId = font.numGlyphs - 1;
}
const glyphZeroId = font instanceof CFFFont ? font.numGlyphs - 1 : 1;
const mapping = font.getGlyphMapping(properties);
let newMapping = null;
let newCharCodeToGlyphId = mapping;
Expand Down
7 changes: 3 additions & 4 deletions src/core/pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@ class RadialAxialShading extends BaseShading {
}
colorStops.push([1, Util.makeHexColor(rPrev, gPrev, bPrev)]);

let background = "transparent";
if (dict.has("Background")) {
background = cs.getRgbHex(dict.get("Background"), 0);
}
const background = dict.has("Background")
? cs.getRgbHex(dict.get("Background"), 0)
: "transparent";

if (!extendStart) {
// Insert a color stop at the front and offset the first real color stop
Expand Down
11 changes: 4 additions & 7 deletions src/core/type1_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,10 @@ class Type1Parser {
subrs,
this.seacAnalysisEnabled
);
let output = charString.output;
if (error) {
// It seems when FreeType encounters an error while evaluating a glyph
// that it completely ignores the glyph so we'll mimic that behaviour
// here and put an endchar to make the validator happy.
output = [14];
}
// It seems when FreeType encounters an error while evaluating a glyph
// that it completely ignores the glyph so we'll mimic that behaviour
// here and put an endchar to make the validator happy.
const output = !error ? charString.output : [14];
const charStringObject = {
glyphName: glyph,
charstring: output,
Expand Down
1 change: 0 additions & 1 deletion src/core/xfa/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class XFAFactory {
const missingFonts = [];
for (let typeface of this.form[$globalData].usedTypefaces) {
typeface = stripQuotes(typeface);
// eslint-disable-next-line unicorn/prefer-array-some
const font = this.form[$globalData].fontFinder.find(typeface);
if (!font) {
missingFonts.push(typeface);
Expand Down
2 changes: 1 addition & 1 deletion src/core/xml_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class XMLParserBase {
return s.replaceAll(/&([^;]+);/g, (all, entity) => {
if (entity.substring(0, 2) === "#x") {
return String.fromCodePoint(parseInt(entity.substring(2), 16));
} else if (entity.substring(0, 1) === "#") {
} else if (entity.at(0) === "#") {
return String.fromCodePoint(parseInt(entity.substring(1), 10));
}
switch (entity) {
Expand Down
15 changes: 6 additions & 9 deletions src/scripting_api/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,9 @@ class EventDispatcher {
this.runCalculate(source, event);

const savedValue = (event.value = source.obj._getValue());
let formattedValue = null;

if (this.runActions(source, source, event, "Format")) {
formattedValue = event.value?.toString?.();
}
const formattedValue = this.runActions(source, source, event, "Format")
? event.value?.toString?.()
: null;

source.obj._send({
id: source.obj._id,
Expand Down Expand Up @@ -365,10 +363,9 @@ class EventDispatcher {
}

savedValue = target.obj._getValue();
let formattedValue = null;
if (this.runActions(target, target, event, "Format")) {
formattedValue = event.value?.toString?.();
}
const formattedValue = this.runActions(target, target, event, "Format")
? event.value?.toString?.()
: null;

target.obj._send({
id: target.obj._id,
Expand Down
6 changes: 5 additions & 1 deletion test/integration/comment_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ describe("Comment", () => {
await page.mouse.down();

const steps = 20;
await page.mouse.move(startX - extraWidth, startY, { steps });
for (let i = 1; i <= steps; i++) {
const x = Math.round(startX - (extraWidth * i) / steps);
await page.mouse.move(x, startY);
await waitForBrowserTrip(page);
}
await page.mouse.up();

const rectAfter = await getRect(page, sidebarSelector);
Expand Down
9 changes: 5 additions & 4 deletions test/resources/reftest-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,11 @@ window.onload = function () {
window.addEventListener("keydown", function keydown(event) {
if (event.which === 84) {
// 't' switch test/ref images
let val = 0;
if (document.querySelector('input[name="which"][value="0"]:checked')) {
val = 1;
}
const val = document.querySelector(
'input[name="which"][value="0"]:checked'
)
? 1
: 0;
document
.querySelector('input[name="which"][value="' + val + '"]')
.click();
Expand Down
11 changes: 8 additions & 3 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
downloadManifestFiles,
verifyManifestFiles,
} from "./downloadutils.mjs";
import { execSync } from "child_process";
import fs from "fs";
import istanbulCoverage from "istanbul-lib-coverage";
import istanbulReportGenerator from "istanbul-reports";
Expand Down Expand Up @@ -1095,9 +1096,13 @@ async function startBrowser({
}

async function startBrowsers({ baseUrl, initializeSession, numSessions = 1 }) {
// Remove old browser revisions from Puppeteer's cache. Updating Puppeteer can
// cause new browser revisions to be downloaded, so trimming the cache will
// prevent the disk from filling up over time.
// Install the browsers.
for (const browser of ["firefox@nightly", "chrome@stable"]) {
execSync(`npx puppeteer browsers install ${browser}`, { stdio: "inherit" });
}

// Remove old browser revisions from Puppeteer's cache. The commands above can
// download new browser revisions, so this prevents the disk from filling up.
await puppeteer.trimCache();

const browserNames = ["firefox", "chrome"];
Expand Down
Loading