Import fs/promises directly in a few spots in the unit-tests

Also, use the existing PDF.js helper function to fetch text-data when running the "bidi" tests in browsers.
This commit is contained in:
Jonas Jenwald 2026-03-30 14:03:09 +02:00
parent 90fe6c70ff
commit bfffb6c0f0
2 changed files with 6 additions and 6 deletions

View File

@ -76,8 +76,8 @@ if (isNodeJS) {
}
async function fetchData(url) {
const fs = process.getBuiltinModule("fs");
const data = await fs.promises.readFile(url);
const fs = process.getBuiltinModule("fs/promises");
const data = await fs.readFile(url);
return new Uint8Array(data);
}

View File

@ -14,6 +14,7 @@
*/
import { bidi } from "../../src/core/bidi.js";
import { fetchData } from "../../src/display/display_utils.js";
import { isNodeJS } from "../../src/shared/util.js";
const BIDI_TEST_DATA_PATH = isNodeJS ? "./test/bidi/" : "../bidi/";
@ -21,11 +22,10 @@ const BIDI_TEST_DATA_PATH = isNodeJS ? "./test/bidi/" : "../bidi/";
async function readTestFile(filename) {
const path = BIDI_TEST_DATA_PATH + filename;
if (isNodeJS) {
const fs = process.getBuiltinModule("fs");
return fs.promises.readFile(path, "utf8");
const fs = process.getBuiltinModule("fs/promises");
return fs.readFile(path, "utf8");
}
const response = await fetch(new URL(path, window.location));
return response.text();
return fetchData(new URL(path, window.location), /* type = */ "text");
}
// Unicode Bidirectional Algorithm tests.