mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-09-13 08:24:55 +00:00
fix: add pdfjs at compatibility polyfill
Agent-Logs-Url: https://github.com/kekingcn/kkFileView/sessions/287f0212-d368-4b59-ae70-0374fb3fe76f Co-authored-by: klboke <18591662+klboke@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
405a12ef07
commit
5499150395
@@ -0,0 +1,32 @@
|
||||
package cn.keking;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PdfViewerCompatibilityTests {
|
||||
|
||||
@Test
|
||||
void shouldLoadCompatibilityModuleBeforePdfJs() throws IOException {
|
||||
String viewerHtml = readResource("/static/pdfjs/web/viewer.html");
|
||||
|
||||
assert viewerHtml.contains("<script src=\"compatibility.mjs\" type=\"module\"></script>");
|
||||
assert viewerHtml.indexOf("compatibility.mjs") < viewerHtml.indexOf("../build/pdf.mjs");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldLoadCompatibilityModuleInPdfWorker() throws IOException {
|
||||
String workerScript = readResource("/static/pdfjs/build/pdf.worker.mjs");
|
||||
|
||||
assert workerScript.contains("import \"../web/compatibility.mjs\";");
|
||||
}
|
||||
|
||||
private String readResource(String resourcePath) throws IOException {
|
||||
try (InputStream inputStream = getClass().getResourceAsStream(resourcePath)) {
|
||||
assert inputStream != null;
|
||||
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user