Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 1 addition & 0 deletions .github/font_tests_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fonttools==4.*
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/fluent_linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ jobs:
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: '.github/fluent_linter_requirements.txt'

- name: Install Fluent dependencies
run: |
pip install -r .github/requirements.txt
- name: Install requirements
run: pip install -r .github/fluent_linter_requirements.txt

- name: Lint Fluent reference files
run: |
moz-fluent-lint ./l10n/en-US --config .github/fluent_linter_config.yml
run: moz-fluent-lint ./l10n/en-US --config .github/fluent_linter_config.yml
6 changes: 4 additions & 2 deletions .github/workflows/font_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand All @@ -55,9 +56,10 @@ jobs:
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: '.github/font_tests_requirements.txt'

- name: Install Fonttools
run: pip install fonttools
- name: Install requirements
run: pip install -r .github/font_tests_requirements.txt

- name: Run font tests
run: npx gulp fonttest --headless
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/prefs_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/types_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update_locales.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: lts/*
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
5 changes: 5 additions & 0 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,11 @@ gulp.task(
removeBOM: false,
})
.pipe(gulp.dest(DIST_DIR)),
gulp
.src("external/dist/webpack.mjs", {
encoding: false,
})
.pipe(gulp.dest(DIST_DIR + "legacy/")),
gulp
.src(GENERIC_DIR + "LICENSE", { encoding: false })
.pipe(gulp.dest(DIST_DIR)),
Expand Down
10 changes: 0 additions & 10 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2099,16 +2099,6 @@ class PDFWorker {
new Blob([wrapper], { type: "text/javascript" })
);
};

this.fromPort = params => {
deprecated(
"`PDFWorker.fromPort` - please use `PDFWorker.create` instead."
);
if (!params?.port) {
throw new Error("PDFWorker.fromPort - invalid method signature.");
}
return this.create(params);
};
}

if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
Expand Down
50 changes: 7 additions & 43 deletions test/downloadutils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

import crypto from "crypto";
import fs from "fs";
import http from "http";
import https from "https";
import { resolve as urlResolve } from "url";

function rewriteWebArchiveUrl(url) {
// Web Archive URLs need to be transformed to add `if_` after the ID.
Expand All @@ -32,54 +29,21 @@ function rewriteWebArchiveUrl(url) {
return url;
}

function downloadFile(file, url, redirects = 0) {
async function downloadFile(file, url) {
url = rewriteWebArchiveUrl(url);
const protocol = /^https:\/\//.test(url) ? https : http;

return new Promise((resolve, reject) => {
protocol
.get(url, async function (response) {
if ([301, 302, 307, 308].includes(response.statusCode)) {
if (redirects > 10) {
response.resume();
reject(new Error("Too many redirects"));
return;
}
const redirectTo = urlResolve(url, response.headers.location);
try {
await downloadFile(file, redirectTo, ++redirects);
resolve();
} catch (ex) {
response.resume();
reject(ex);
}
return;
}

if (response.statusCode !== 200) {
response.resume();
reject(new Error(`HTTP ${response.statusCode}`));
return;
}

const stream = fs.createWriteStream(file);
stream.on("error", error => reject(error));
stream.on("finish", () => {
stream.end();
resolve();
});
response.pipe(stream);
})
.on("error", error => reject(error));
});
const response = await fetch(url);
if (!response.ok) {
throw new Error(response.statusText);
}
return fs.promises.writeFile(file, response.body);
}

async function downloadManifestFiles(manifest) {
const links = manifest
.filter(item => item.link && !fs.existsSync(item.file))
.map(item => {
let url = fs.readFileSync(`${item.file}.link`).toString();
url = url.replace(/\s+$/, "");
const url = fs.readFileSync(`${item.file}.link`).toString().trimEnd();
return { file: item.file, url };
});

Expand Down
12 changes: 12 additions & 0 deletions test/integration/reorganize_pages_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,9 @@ describe("Reorganize Pages View", () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await waitForThumbnailVisible(page, 1);
const labelSelector = "#viewsManagerStatusActionLabel";
await waitForTextToBe(page, labelSelector, "Select pages");

await waitAndClick(
page,
`.thumbnail:has(${getThumbnailSelector(1)}) input`
Expand All @@ -1899,6 +1902,8 @@ describe("Reorganize Pages View", () => {
`.thumbnail:has(${getThumbnailSelector(3)}) input`
);

await waitForTextToBe(page, labelSelector, `${FSI}2${PDI} selected`);

const handleExport = await createPromise(page, resolve => {
window.PDFViewerApplication.eventBus.on(
"saveextractedpages",
Expand All @@ -1919,6 +1924,13 @@ describe("Reorganize Pages View", () => {
.toEqual([
{ document: null, pageIndices: [0, 1], includePages: [0, 2] },
]);

await waitForTextToBe(page, labelSelector, "Select pages");
// All checkboxes should be unchecked.
await page.waitForSelector(
"#thumbnailsView:not(:has(input:checked))",
{ visible: true }
);
})
);
});
Expand Down
37 changes: 36 additions & 1 deletion test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,38 @@ import { WebServer } from "./webserver.mjs";

const __dirname = import.meta.dirname;

// Strip private ancillary PNG chunks before comparing snapshots. Firefox adds
// a `deBG` chunk with a per-session unique ID to canvas.toDataURL("image/png")
// output, causing false failures when ref and test were captured in different
// browser sessions.
// For reference:
// https://searchfox.org/firefox-main/rev/1427c88632d1474d2653928745d78feca1a64ee0/image/encoders/png/nsPNGEncoder.cpp#367
function stripPrivatePngChunks(buf) {
const PNG_SIGNATURE = 8;
let pos = PNG_SIGNATURE;
const chunks = [];
const pre_chunk_data = 8; // len (4) + type (4)
const post_chunk_data = 4; // CRC
while (pos < buf.length) {
const len = buf.readUInt32BE(pos);
const type = buf.slice(pos + 4, pos + 8).toString("latin1");
const to_skip = pre_chunk_data + len + post_chunk_data;
// Keep critical chunks (uppercase first letter) and public ancillary
// chunks (uppercase second letter). Drop private ancillary chunks
// (lowercase second letter), e.g. "deBG" added by Firefox.
// See PNG specification for details on chunk types:
// https://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#:~:text=4%2E3%2E,-Summary
if (
type[0] === type[0].toUpperCase() ||
type[1] === type[1].toUpperCase()
) {
chunks.push(buf.slice(pos, pos + to_skip));
}
pos += to_skip;
}
return Buffer.concat([buf.slice(0, PNG_SIGNATURE), ...chunks]);
}

function parseOptions() {
const { values } = parseArgs({
args: process.argv.slice(2),
Expand Down Expand Up @@ -395,7 +427,9 @@ function checkEq(task, results, browser, masterMode) {
}
} else {
refSnapshot = fs.readFileSync(refPath);
eq = refSnapshot.toString("hex") === testSnapshot.toString("hex");
eq =
stripPrivatePngChunks(refSnapshot).toString("hex") ===
stripPrivatePngChunks(testSnapshot).toString("hex");
if (!eq) {
console.log(
"TEST-UNEXPECTED-FAIL | " +
Expand Down Expand Up @@ -899,6 +933,7 @@ async function startBrowser({
"browser.ml.linkPreview.enabled": false,
"browser.tabs.groups.smart.enabled": false,
"browser.tabs.groups.smart.userEnabled": false,
"privacy.baselineFingerprintingProtection": false,
...extraPrefsFirefox,
};
}
Expand Down
1 change: 1 addition & 0 deletions web/pdf_thumbnail_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ class PDFThumbnailViewer {
});
this.#clearSelection();
this.#toggleMenuEntries(false);
this.#updateStatus("select");
}

#copyPages(clearSelection = true) {
Expand Down
Loading