diff --git a/extensions/browser/src/browser/cdp.helpers.fuzz.test.ts b/extensions/browser/src/browser/cdp.helpers.fuzz.test.ts index 94236a67756..dcd687fe819 100644 --- a/extensions/browser/src/browser/cdp.helpers.fuzz.test.ts +++ b/extensions/browser/src/browser/cdp.helpers.fuzz.test.ts @@ -200,7 +200,7 @@ describe("fuzz: isDirectCdpWebSocketEndpoint", () => { } }); - it("never throws on random input (including invalid URLs)", () => { + it("returns booleans for random input including invalid URLs", () => { const rng = makeRng(0x2004); const junkPool = [ "", @@ -215,7 +215,6 @@ describe("fuzz: isDirectCdpWebSocketEndpoint", () => { ]; for (let i = 0; i < ITERATIONS; i += 1) { const input = rng() < 0.5 ? pick(rng, junkPool) : String.fromCharCode(randInt(rng, 0, 0x7f)); - expect(() => isDirectCdpWebSocketEndpoint(input)).not.toThrow(); expect(typeof isDirectCdpWebSocketEndpoint(input)).toBe("boolean"); } }); @@ -271,12 +270,12 @@ describe("fuzz: normalizeCdpHttpBaseForJsonEndpoints", () => { } }); - it("falls back safely for non-URL-ish inputs (never throws)", () => { + it("returns normalized strings for non-URL-ish inputs", () => { const rng = makeRng(0x3003); // These inputs either trigger the catch branch (empty / "garbage" / // bare "ws://" / "wss://") or are accepted by WHATWG URL as // special-scheme absolute URLs (e.g. "ws:host/path" becomes - // "ws://host/path"). Either way the helper must never throw. + // "ws://host/path"). Both paths must return strings. const junk = [ "ws:/devtools/browser/abc", "wss:/devtools/browser/abc", @@ -289,7 +288,6 @@ describe("fuzz: normalizeCdpHttpBaseForJsonEndpoints", () => { ]; for (let i = 0; i < ITERATIONS; i += 1) { const input = pick(rng, junk); - expect(() => normalizeCdpHttpBaseForJsonEndpoints(input)).not.toThrow(); const out = normalizeCdpHttpBaseForJsonEndpoints(input); expect(typeof out).toBe("string"); // Scheme swap invariant: whatever branch ran, ws:/wss: never @@ -377,11 +375,10 @@ describe("fuzz: redactCdpUrl", () => { expect(redactCdpUrl(" ")).toBe(""); }); - it("falls back to redactSensitiveText for non-URL-ish inputs (never throws)", () => { + it("falls back to redactSensitiveText for non-URL-ish inputs", () => { const rng = makeRng(0x5002); for (let i = 0; i < ITERATIONS; i += 1) { const junk = pick(rng, ["not-a-url", "http://", "ws://", "::::", "Bearer ey.SECRET.xyz"]); - expect(() => redactCdpUrl(junk)).not.toThrow(); const out = redactCdpUrl(junk); expect(typeof out).toBe("string"); } @@ -405,7 +402,7 @@ describe("fuzz: appendCdpPath", () => { }); describe("fuzz: getHeadersWithAuth", () => { - it("never throws and always returns a mergedHeaders object", () => { + it("always returns a mergedHeaders object", () => { const rng = makeRng(0x7001); for (let i = 0; i < ITERATIONS; i += 1) { const withAuth = rng() < 0.3;