diff --git a/test/font/ttxdriver.mjs b/test/font/ttxdriver.mjs index c820d8ccf..3e51caa4b 100644 --- a/test/font/ttxdriver.mjs +++ b/test/font/ttxdriver.mjs @@ -21,14 +21,9 @@ import { spawn } from "child_process"; let ttxTaskId = Date.now(); -function runTtx(fontPath, registerOnCancel, callback) { +function runTtx(fontPath, callback) { const ttx = spawn("ttx", [fontPath], { stdio: "ignore" }); let ttxRunError; - registerOnCancel(function (reason) { - ttxRunError = reason; - callback(reason); - ttx.kill(); - }); ttx.on("error", function (errorTtx) { ttxRunError = errorTtx; callback( @@ -43,14 +38,14 @@ function runTtx(fontPath, registerOnCancel, callback) { }); } -function translateFont(content, registerOnCancel, callback) { +function translateFont(content, callback) { const buffer = Buffer.from(content, "base64"); const taskId = (ttxTaskId++).toString(); const fontPath = path.join(os.tmpdir(), `pdfjs-font-test-${taskId}.otf`); const resultPath = path.join(os.tmpdir(), `pdfjs-font-test-${taskId}.ttx`); fs.writeFileSync(fontPath, buffer); - runTtx(fontPath, registerOnCancel, function (err) { + runTtx(fontPath, function (err) { fs.unlinkSync(fontPath); if (err) { console.error(err); diff --git a/test/test.mjs b/test/test.mjs index 1080be89d..a6a1e76b4 100644 --- a/test/test.mjs +++ b/test/test.mjs @@ -842,22 +842,10 @@ function unitTestPostHandler(req, res) { }); req.on("end", function () { if (pathname === "/ttx") { - var onCancel = null, - ttxTimeout = 10000; - var timeoutId = setTimeout(function () { - onCancel?.("TTX timeout"); - }, ttxTimeout); - translateFont( - body, - function (fn) { - onCancel = fn; - }, - function (err, xml) { - clearTimeout(timeoutId); - res.writeHead(200, { "Content-Type": "text/xml" }); - res.end(err ? "" + err + "" : xml); - } - ); + translateFont(body, function (err, xml) { + res.writeHead(200, { "Content-Type": "text/xml" }); + res.end(err ? "" + err + "" : xml); + }); return; }