






















@@ -200,7 +200,7 @@ describe("fuzz: isDirectCdpWebSocketEndpoint", () => {
200200}
201201});
202202203-it("never throws on random input (including invalid URLs)", () => {
203+it("returns booleans for random input including invalid URLs", () => {
204204const rng = makeRng(0x2004);
205205const junkPool = [
206206"",
@@ -215,7 +215,6 @@ describe("fuzz: isDirectCdpWebSocketEndpoint", () => {
215215];
216216for (let i = 0; i < ITERATIONS; i += 1) {
217217const input = rng() < 0.5 ? pick(rng, junkPool) : String.fromCharCode(randInt(rng, 0, 0x7f));
218-expect(() => isDirectCdpWebSocketEndpoint(input)).not.toThrow();
219218expect(typeof isDirectCdpWebSocketEndpoint(input)).toBe("boolean");
220219}
221220});
@@ -271,12 +270,12 @@ describe("fuzz: normalizeCdpHttpBaseForJsonEndpoints", () => {
271270}
272271});
273272274-it("falls back safely for non-URL-ish inputs (never throws)", () => {
273+it("returns normalized strings for non-URL-ish inputs", () => {
275274const rng = makeRng(0x3003);
276275// These inputs either trigger the catch branch (empty / "garbage" /
277276// bare "ws://" / "wss://") or are accepted by WHATWG URL as
278277// special-scheme absolute URLs (e.g. "ws:host/path" becomes
279-// "ws://host/path"). Either way the helper must never throw.
278+// "ws://host/path"). Both paths must return strings.
280279const junk = [
281280"ws:/devtools/browser/abc",
282281"wss:/devtools/browser/abc",
@@ -289,7 +288,6 @@ describe("fuzz: normalizeCdpHttpBaseForJsonEndpoints", () => {
289288];
290289for (let i = 0; i < ITERATIONS; i += 1) {
291290const input = pick(rng, junk);
292-expect(() => normalizeCdpHttpBaseForJsonEndpoints(input)).not.toThrow();
293291const out = normalizeCdpHttpBaseForJsonEndpoints(input);
294292expect(typeof out).toBe("string");
295293// Scheme swap invariant: whatever branch ran, ws:/wss: never
@@ -377,11 +375,10 @@ describe("fuzz: redactCdpUrl", () => {
377375expect(redactCdpUrl(" ")).toBe("");
378376});
379377380-it("falls back to redactSensitiveText for non-URL-ish inputs (never throws)", () => {
378+it("falls back to redactSensitiveText for non-URL-ish inputs", () => {
381379const rng = makeRng(0x5002);
382380for (let i = 0; i < ITERATIONS; i += 1) {
383381const junk = pick(rng, ["not-a-url", "http://", "ws://", "::::", "Bearer ey.SECRET.xyz"]);
384-expect(() => redactCdpUrl(junk)).not.toThrow();
385382const out = redactCdpUrl(junk);
386383expect(typeof out).toBe("string");
387384}
@@ -405,7 +402,7 @@ describe("fuzz: appendCdpPath", () => {
405402});
406403407404describe("fuzz: getHeadersWithAuth", () => {
408-it("never throws and always returns a mergedHeaders object", () => {
405+it("always returns a mergedHeaders object", () => {
409406const rng = makeRng(0x7001);
410407for (let i = 0; i < ITERATIONS; i += 1) {
411408const withAuth = rng() < 0.3;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。