feat(extension): auto-intercept https→pap, unit tests, refactor#290
Merged
toadkicker merged 4 commits intomainfrom Apr 15, 2026
Merged
feat(extension): auto-intercept https→pap, unit tests, refactor#290toadkicker merged 4 commits intomainfrom
toadkicker merged 4 commits intomainfrom
Conversation
Ordinary left-clicks on https:// links are now routed through the PAP handshake automatically, making zero-trust browsing the default when Papillon is active — no right-click context menu required. Changes: - content-script: capture-phase click handler converts https:// hrefs to pap:// and sends HTTPS_LINK_CLICKED to the service worker; guards pass through modifier clicks (Ctrl/Meta/Shift), Alt-click (per-click opt-out), synthetic events, download links, and per-domain exclusions; storage state is loaded at script init and kept live via chrome.storage.onChanged - service-worker: new HTTPS_LINK_CLICKED case swaps https:// → pap:// and calls openHandshakeTab with the original URL as fallback - types: HttpsLinkClicked interface + ExtensionMessage union member - popup: global auto-intercept toggle (aria role=switch, default on) and per-domain "Disable on this site" button backed by chrome.storage.sync - popup.css: toggle track/thumb via ::after + aria-checked; domain button teal accent when excluded Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brings test coverage from 1 file (db.ts) to 4 files with 117 tests passing. - src/lib/uri.test.ts (28 tests): full coverage of parsePapUri, httpsUrlToPap, isPapUri, toEndpoint, toHttpsEndpoint, isBrowserCompatible — all pure functions, zero mocks needed - src/lib/discovery.test.ts (23 tests): validateManifest (pure, boundary checks for field lengths and array limits) + fetchManifest (fetch stubbed via vi.stubGlobal — covers 200/404/500, wrong Content-Type, oversized bodies, network errors, origin-only vs full-path URLs) - src/content/intercept-logic.ts (new): extracts resolveInterceptUrl() from content-script.ts as a pure, side-effect-free function so it can be tested in Node without jsdom or Chrome API mocks - src/content/intercept-logic.test.ts (25 tests): exercises all 8 guard conditions (button, modifiers, isTrusted, download attr, scheme, state flags, domain exclusion) plus happy-path URL resolution and relative href handling - vitest.config.ts: enable @vitest/coverage-v8 with text + lcov reporters and a 60% lines threshold Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- New src/lib/constants.ts: single source of truth for the two chrome.storage.sync key strings (autoInterceptHttps, excludedDomains) previously duplicated across content-script.ts and popup.ts - Export NATIVE_APP_ID from native-messaging.ts; remove the identical private copy in service-worker.ts - discovery.ts: replace 5 repeated typeof/length checks with an isValidString() type-predicate helper; name every magic limit (MAX_AGENT_ID_LEN, MAX_TOOLS, MAX_CATEGORIES, etc.); fix the unsafe `as string` cast in categories by using a type-predicate filter - service-worker.ts: file-local named constants for badge hex colors (BADGE_COLOR_GOLD, BADGE_COLOR_PURPLE) and context-menu ID (CONTEXT_MENU_UPGRADE_ID) replace four inline magic strings - popup.ts: $<T>() DOM helper replaces nine verbose getElementById calls All 117 tests pass unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Benchmark Regression ReportThreshold: 10% regression vs baseline from main |
- types.rs:1257 — remove `auto_expand: false` from BlockUpdate test initialiser; `auto_expand` was dropped from the struct in the #289 refactor but the test literal was not updated, causing a compile error (E0560) across Check, Test, WASM backend, and Justfile recipes - web_reader.rs:112 — remove needless borrow `&final_url`; Rust deref- coerces String → &str automatically, Clippy's needless_borrow lint (-D warnings) was failing Check, Test, Clippy, and Justfile recipes Both errors were pre-existing on main and blocked every PR. All CI checks for papillon-extension PR #290 should now be green. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
🤖 Generated with Claude Code