mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-12 10:05:47 +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) {
|
async function fetchData(url) {
|
||||||
const fs = process.getBuiltinModule("fs");
|
const fs = process.getBuiltinModule("fs/promises");
|
||||||
const data = await fs.promises.readFile(url);
|
const data = await fs.readFile(url);
|
||||||
return new Uint8Array(data);
|
return new Uint8Array(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { bidi } from "../../src/core/bidi.js";
|
import { bidi } from "../../src/core/bidi.js";
|
||||||
|
import { fetchData } from "../../src/display/display_utils.js";
|
||||||
import { isNodeJS } from "../../src/shared/util.js";
|
import { isNodeJS } from "../../src/shared/util.js";
|
||||||
|
|
||||||
const BIDI_TEST_DATA_PATH = isNodeJS ? "./test/bidi/" : "../bidi/";
|
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) {
|
async function readTestFile(filename) {
|
||||||
const path = BIDI_TEST_DATA_PATH + filename;
|
const path = BIDI_TEST_DATA_PATH + filename;
|
||||||
if (isNodeJS) {
|
if (isNodeJS) {
|
||||||
const fs = process.getBuiltinModule("fs");
|
const fs = process.getBuiltinModule("fs/promises");
|
||||||
return fs.promises.readFile(path, "utf8");
|
return fs.readFile(path, "utf8");
|
||||||
}
|
}
|
||||||
const response = await fetch(new URL(path, window.location));
|
return fetchData(new URL(path, window.location), /* type = */ "text");
|
||||||
return response.text();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unicode Bidirectional Algorithm tests.
|
// Unicode Bidirectional Algorithm tests.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user