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
28 changes: 1 addition & 27 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ function getTempFile(prefix, suffix) {
return filePath;
}

function runTests(testsName, { bot = false, xfaOnly = false } = {}) {
function runTests(testsName, { bot = false } = {}) {
return new Promise((resolve, reject) => {
console.log("\n### Running " + testsName + " tests");

Expand All @@ -696,9 +696,6 @@ function runTests(testsName, { bot = false, xfaOnly = false } = {}) {
// causing a timeout, hence disabling them for now.
forceNoChrome = true;
}
if (xfaOnly) {
args.push("--xfaOnly");
}
args.push("--manifestFile=" + PDF_TEST);
collectArgs(
{
Expand Down Expand Up @@ -1811,29 +1808,6 @@ gulp.task(
})
);

gulp.task(
"xfatest",
gulp.series(setTestEnv, "generic", "components", async function runXfaTest() {
await runTests("unit");
await runTests("browser", { xfaOnly: true });
await runTests("integration");
})
);

gulp.task(
"botxfatest",
gulp.series(
setTestEnv,
"generic",
"components",
async function runBotXfaTest() {
await runTests("unit", { bot: true });
await runTests("browser", { bot: true, xfaOnly: true });
await runTests("integration");
}
)
);

gulp.task(
"browsertest",
gulp.series(
Expand Down
8 changes: 5 additions & 3 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2948,9 +2948,12 @@ class PartialEvaluator {
}

const font = textState.font;
const baseCharSpacing = font.vertical
? -textState.charSpacing
: textState.charSpacing;
if (!chars) {
// Just move according to the space we have.
const charSpacing = textState.charSpacing + extraSpacing;
const charSpacing = baseCharSpacing + extraSpacing;
if (charSpacing) {
if (!font.vertical) {
textState.translateTextMatrix(
Expand Down Expand Up @@ -2979,8 +2982,7 @@ class PartialEvaluator {
if (category.isInvisibleFormatMark) {
continue;
}
let charSpacing =
textState.charSpacing + (i + 1 === ii ? extraSpacing : 0);
let charSpacing = baseCharSpacing + (i + 1 === ii ? extraSpacing : 0);

let glyphWidth = glyph.width;
if (font.vertical) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3407,7 +3407,7 @@ class Font {
if (typeof width !== "number") {
width = this.defaultWidth;
}
const vmetric = this.vmetrics?.[widthCode];
const vmetric = this.vmetrics?.[widthCode] || this.defaultVMetrics;

let unicode = this.toUnicode.get(charcode) || charcode;
if (typeof unicode === "number") {
Expand Down
6 changes: 1 addition & 5 deletions test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ class Driver {
this.delay = params.get("delay") | 0;
this.inFlightRequests = 0;
this.testFilter = JSON.parse(params.get("testfilter") || "[]");
this.xfaOnly = params.get("xfaonly") === "true";
this.masterMode = params.get("mastermode") === "true";

// Create a working canvas
Expand Down Expand Up @@ -544,14 +543,11 @@ class Driver {
this._log("done\n");
this.manifest = await response.json();

if (this.testFilter?.length || this.xfaOnly) {
if (this.testFilter?.length) {
this.manifest = this.manifest.filter(item => {
if (this.testFilter.includes(item.id)) {
return true;
}
if (this.xfaOnly && item.enableXfa) {
return true;
}
return false;
});
}
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -889,3 +889,4 @@
!mesh_shading_empty.pdf
!acroform_calculation_order.pdf
!extractPages_null_in_array.pdf
!issue20930.pdf
Binary file added test/pdfs/issue20930.pdf
Binary file not shown.
24 changes: 3 additions & 21 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function parseOptions() {
strictVerify: { type: "boolean", default: false },
testfilter: { type: "string", short: "t", multiple: true, default: [] },
unitTest: { type: "boolean", default: false },
xfaOnly: { type: "boolean", default: false },
},
});

Expand All @@ -83,8 +82,7 @@ function parseOptions() {
" --statsFile File where to store stats.\n" +
" --strictVerify Error if manifest file verification fails.\n" +
" --testfilter, -t Run specific reftest(s), e.g. -t=issue5567.\n" +
" --unitTest Run the unit tests.\n" +
" --xfaOnly Only run the XFA reftest(s)."
" --unitTest Run the unit tests.\n"
);
process.exit(0);
}
Expand All @@ -97,17 +95,6 @@ function parseOptions() {
"--reftest, --unitTest, --fontTest, and --masterMode must not be specified together."
);
}
if (
+values.unitTest + values.fontTest + values.integration + values.xfaOnly >
1
) {
throw new Error(
"--unitTest, --fontTest, --integration, and --xfaOnly must not be specified together."
);
}
if (values.testfilter.length > 0 && values.xfaOnly) {
throw new Error("--testfilter and --xfaOnly cannot be used together.");
}
if (values.noDownload && values.downloadOnly) {
throw new Error("--noDownload and --downloadOnly cannot be used together.");
}
Expand Down Expand Up @@ -347,18 +334,14 @@ function handleSessionTimeout(session) {
function getTestManifest() {
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));

const testFilter = options.testfilter.slice(0),
xfaOnly = options.xfaOnly;
if (testFilter.length || xfaOnly) {
const testFilter = options.testfilter.slice(0);
if (testFilter.length) {
manifest = manifest.filter(function (item) {
var i = testFilter.indexOf(item.id);
if (i !== -1) {
testFilter.splice(i, 1);
return true;
}
if (xfaOnly && item.enableXfa) {
return true;
}
return false;
});
if (testFilter.length) {
Expand Down Expand Up @@ -968,7 +951,6 @@ async function startBrowsers({ baseUrl, initializeSession }) {
`?browser=${encodeURIComponent(browserName)}` +
`&manifestFile=${encodeURIComponent("/test/" + options.manifestFile)}` +
`&testFilter=${JSON.stringify(options.testfilter)}` +
`&xfaOnly=${options.xfaOnly}` +
`&delay=${options.statsDelay}` +
`&masterMode=${options.masterMode}`;
startUrl = baseUrl + queryParameters;
Expand Down
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14005,5 +14005,12 @@
"md5": "5a1bf9cb73010d84b47d91bb66bae27d",
"rounds": 1,
"type": "eq"
},
{
"id": "issue20930-text",
"file": "pdfs/issue20930.pdf",
"md5": "321f0901af604a6052baa7b2855a7e3e",
"rounds": 1,
"type": "text"
}
]
9 changes: 9 additions & 0 deletions web/internal/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ gotoInput.addEventListener("keydown", async ({ key, target }) => {
return;
}
target.removeAttribute("aria-invalid");

// Allow debugging via references, as well as page numbers.
if (result.page === undefined) {
try {
result.page =
pdfDoc.cachedPageNumber(result.ref) ??
(await pdfDoc.getPageIndex(result.ref)) + 1;
} catch {}
}
// If we're in debug view and navigating to a page, stay in debug view
// without switching to the tree at all.
if (!debugViewEl.hidden && result.page !== undefined) {
Expand Down
5 changes: 3 additions & 2 deletions web/text_layer_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ class TextLayerBuilder {
#bindMouse(end) {
const { div } = this;
const abortSignal = this.#abortSignal;
const opts = abortSignal ? { signal: abortSignal } : null;

div.addEventListener(
"mousedown",
() => {
div.classList.add("selecting");
},
{ signal: abortSignal }
opts
);

div.addEventListener(
Expand All @@ -190,7 +191,7 @@ class TextLayerBuilder {
}
stopEvent(event);
},
{ signal: abortSignal }
opts
);

TextLayerBuilder.#textLayers.set(div, end);
Expand Down
Loading