test(browser): pin DOM and source-map URL policy classifications (#1120)

* test(browser): pin DOM and source-map URL policy classifications

Cover the unsupported DOM scope, credentialed destinations, and the source-map fetcher's pre-request filtering of credentials, other origins and non-http(s) URLs, so a later vocabulary unification can show exactly what changes.

Refs #829

* test(browser): assert exact sanitized credentialed DOM URL

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Hasan Mehdi Rizvi
2026-10-09 06:57:40 +08:00
committed by GitHub
co-authored by morluto
parent e8939ca220
commit c1d0002470
2 changed files with 69 additions and 0 deletions
@@ -100,6 +100,44 @@ describe("DOM metadata document base URLs", () => {
});
});
it.each([
"javascript:void(0)",
"mailto:someone@example.test",
"data:text/plain,hello",
"ftp://app.example.test/file",
])("classifies the non-http(s) destination %s as unsupported", (href) => {
const result = capture(snapshot(undefined, "assets/", documentUrl, href));
expect(result.urls[1]).toMatchObject({
url: null,
destination_scope: "unsupported",
});
});
it("classifies an unparseable destination as unsupported", () => {
const result = capture(
snapshot(undefined, "assets/", documentUrl, "https://[invalid"),
);
expect(result.urls[1]).toMatchObject({
url: null,
destination_scope: "unsupported",
});
});
it("classifies a same-origin destination with credentials as approved", () => {
const result = capture(
snapshot(
undefined,
"assets/",
documentUrl,
"https://user:secret@app.example.test/guide",
),
);
expect(result.urls[1]).toMatchObject({
url: `${origin}/guide`,
destination_scope: "approved",
});
});
it("does not authorize a foreign document using its approved base URL", () => {
const result = capture(
snapshot(