Source code
Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
import { proxiedIconUrl } from "content-src/lib/web-notification-icon.mjs";
describe("web-notification-icon", () => {
describe("proxiedIconUrl", () => {
it("routes an https icon through the image proxy", () => {
});
it("requests 2x the rendered size and strips exif", () => {
expect(url).toContain("/64x64/");
expect(url).toContain("strip_exif()");
expect(url).toContain("no_upscale()");
});
it("encodes an icon url containing a query string", () => {
const url = proxiedIconUrl(icon);
expect(url).toContain(encodeURIComponent(icon));
// The origin url must not leak out of its encoded segment.
expect(url).not.toContain("?size=1");
});
it("returns null for a non-https icon rather than passing it through", () => {
// eslint-disable-next-line sdl/no-insecure-url
expect(proxiedIconUrl("data:image/png;base64,AAAA")).toBeNull();
});
it("returns null for missing or malformed input", () => {
expect(proxiedIconUrl(undefined)).toBeNull();
expect(proxiedIconUrl("")).toBeNull();
expect(proxiedIconUrl("not a url")).toBeNull();
});
});
});