ext(sw): expand active-tab URL filter; isolate chrome stub in tests

Expand get_active_tab_url protocol filter regex to include view-source:,
data:, devtools:, and other browser-internal/extension contexts that would
misbehave if autofilled. Add third regression test for view-source: URLs.

Wrap get_active_tab_url tests in dedicated describe block with beforeEach/
afterEach to snapshot/restore globalThis.chrome, preventing stub leakage
between tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-05-01 17:01:36 -04:00
parent f872ab5183
commit 918fdef519
2 changed files with 20 additions and 2 deletions

View File

@@ -153,7 +153,7 @@ export async function handle(
const tab = tabs[0];
if (!tab?.url) return { ok: true, data: null };
// Filter out chrome:// and extension URLs — autofill doesn't apply.
if (/^(chrome|chrome-extension|moz-extension|edge|about|file):/i.test(tab.url)) {
if (/^(chrome|chrome-extension|chrome-search|moz-extension|edge|edge-extension|about|file|view-source|data|devtools|javascript):/i.test(tab.url)) {
return { ok: true, data: null };
}
return { ok: true, data: { url: tab.url, title: tab.title ?? '' } };