mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Remove PDFWorkerUtil
and move its contents into PDFWorker
instead
This is possible thanks to features, i.e. private fields and in particular static initialization blocks, that didn't exist back when we started using classes in the code-base.
This commit is contained in:
parent
582866ee50
commit
c4fdb28573
2 changed files with 75 additions and 78 deletions
|
@ -43,7 +43,6 @@ import {
|
|||
PDFDocumentProxy,
|
||||
PDFPageProxy,
|
||||
PDFWorker,
|
||||
PDFWorkerUtil,
|
||||
RenderTask,
|
||||
} from "../../src/display/api.js";
|
||||
import {
|
||||
|
@ -929,6 +928,31 @@ describe("api", function () {
|
|||
expect(typeof workerSrc).toEqual("string");
|
||||
expect(workerSrc).toEqual(GlobalWorkerOptions.workerSrc);
|
||||
});
|
||||
|
||||
describe("isSameOrigin", function () {
|
||||
it("handles invalid base URLs", function () {
|
||||
// The base URL is not valid.
|
||||
expect(PDFWorker._isSameOrigin("/foo", "/bar")).toEqual(false);
|
||||
|
||||
// The base URL has no origin.
|
||||
expect(PDFWorker._isSameOrigin("blob:foo", "/bar")).toEqual(false);
|
||||
});
|
||||
|
||||
it("correctly checks if the origin of both URLs matches", function () {
|
||||
expect(
|
||||
PDFWorker._isSameOrigin(
|
||||
"https://www.mozilla.org/foo",
|
||||
"https://www.mozilla.org/bar"
|
||||
)
|
||||
).toEqual(true);
|
||||
expect(
|
||||
PDFWorker._isSameOrigin(
|
||||
"https://www.mozilla.org/foo",
|
||||
"https://www.example.com/bar"
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("GlobalWorkerOptions", function () {
|
||||
|
@ -4885,33 +4909,4 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe("PDFWorkerUtil", function () {
|
||||
describe("isSameOrigin", function () {
|
||||
const { isSameOrigin } = PDFWorkerUtil;
|
||||
|
||||
it("handles invalid base URLs", function () {
|
||||
// The base URL is not valid.
|
||||
expect(isSameOrigin("/foo", "/bar")).toEqual(false);
|
||||
|
||||
// The base URL has no origin.
|
||||
expect(isSameOrigin("blob:foo", "/bar")).toEqual(false);
|
||||
});
|
||||
|
||||
it("correctly checks if the origin of both URLs matches", function () {
|
||||
expect(
|
||||
isSameOrigin(
|
||||
"https://www.mozilla.org/foo",
|
||||
"https://www.mozilla.org/bar"
|
||||
)
|
||||
).toEqual(true);
|
||||
expect(
|
||||
isSameOrigin(
|
||||
"https://www.mozilla.org/foo",
|
||||
"https://www.example.com/bar"
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue