/** * Realistic test fixtures for benchmarking web extension hot paths. * Sizes match real-world inputs. */ // ── DDG search result HTML (~20KB) ─────────────────────────────────────── export function makeDdgHtml(resultCount = 15): string { const results: string[] = []; for (let i = 0; i < resultCount; i++) { results.push(` `); } return ` DuckDuckGo Search
header content
${results.join("\n")}
`; } // ── HTML page with injection vectors (~50KB) ────────────────────────────── export function makeHtmlWithInjection(contentSizeKb = 40): string { const content = "A".repeat(contentSizeKb * 1024); return ` Test Page

Article Title

${content.substring(0, 2000)}

More content with & entities <test> and stuff.

  • Item 1
  • Item 2
  • Item 3
Fake instruction hidden

${content.substring(2000, 4000)}

`; } // ── Plain HTML article (~100KB) ────────────────────────────────────────── export function makeLargeArticle(sizeKb = 100): string { const paragraphs = []; for (let i = 0; i < sizeKb * 2; i++) { paragraphs.push(`

Paragraph ${i}: ${"x".repeat(500)}

`); } return ` Large Article

Large Article Title

${paragraphs.join("\n ")}
`; } // ── Pandoc output with residual tags (~50KB) ───────────────────────────── export function makePandocOutput(sizeKb = 40): string { const lines: string[] = []; for (let i = 0; i < sizeKb * 10; i++) { if (i % 50 === 0) { lines.push(`
`); } else if (i % 50 === 49) { lines.push(`
`); } else if (i % 20 === 0) { lines.push(`Some highlighted text ${i}`); } else { lines.push( `This is line ${i} of the markdown output with some **bold** and *italic* text.`, ); } } return lines.join("\n"); } // ── HTML with table classes (~20KB) ────────────────────────────────────── export function makeTableHtml(tableCount = 10): string { let html = "
"; for (let t = 0; t < tableCount; t++) { html += ``; for (let r = 0; r < 20; r++) { html += ``; } html += `
Col ACol B
Row ${r}Value ${r}AValue ${r}B
`; } html += "
"; return html; } // ── HTML entities stress test (~5KB) ────────────────────────────────────── export function makeEntityHeavyText(count = 200): string { const parts: string[] = []; for (let i = 0; i < count; i++) { parts.push( `Entity & test <${i}> with 'quotes' and "double"  space /slash €emoji`, ); } return parts.join(" "); } // ── Chunk arrays for Buffer.concat benchmark ───────────────────────────── export function makeChunks(chunkCount = 100, chunkSizeKb = 10): Uint8Array[] { const chunks: Uint8Array[] = []; for (let i = 0; i < chunkCount; i++) { chunks.push(new Uint8Array(chunkSizeKb * 1024).fill(i % 256)); } return chunks; }