mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-13 00:34:04 +02:00
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:
parent
90fe6c70ff
commit
bfffb6c0f0
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user