Files
2026-11-11 20:24:24 +01:00
..
2026-11-11 20:24:24 +01:00
2026-11-11 20:24:24 +01:00
2026-11-11 20:24:24 +01:00
2026-11-11 20:24:24 +01:00
2026-11-11 20:24:24 +01:00
2026-11-11 20:24:24 +01:00
2026-11-11 20:24:24 +01:00

Test harness

Drives the real extension in real Firefox through Selenium and asserts on the browser's own tab state.

build-test-extension.sh   copies the extension to /tmp/tabpark-test-build and
                          adds the test hook (fixture host permission, content
                          script, background hook)
test-hook-content.js      forwards page messages to the background
test-hook-background.js   exposes tuUnloadOtherTabs / tuUnloadActiveTab / tuSweep
                          plus pin, activate, close, settings and state
driver.py                 the main test
protect.py                the per-tab exception test

Requirements: firefox-esr, python3-selenium, geckodriver, Xvfb. On this host geckodriver lives at /tmp/rig/bin/geckodriver; override with GECKODRIVER=....

Xvfb :99 -screen 0 1280x1024x24 -nolisten tcp &
DISPLAY=:99 python3 test/harness/driver.py
DISPLAY=:99 python3 test/harness/no-tabs.py
DISPLAY=:99 python3 test/harness/protect.py

driver.py adds the tabs permission to the test variant only, so the hook can identify tabs by URL. The extension code never reads tab URLs. no-tabs.py builds without it and identifies tabs by id, matching the shipped permission set exactly.

The driver serves /p1 ... /p6 from 127.0.0.1:8765 and counts hits, so a reload after unloading is observable independently of the extension.

Covered:

  • unload others: keeps the active tab, discards every other non-pinned tab, leaves the pinned tab loaded, tab count unchanged
  • unload current: focus moves to the next loaded tab before the old tab is discarded; keeps the tab count
  • unload current on a blank tab: refused, nothing changes, pressing again is still a no-op
  • unload current when nothing else is loaded: opens a new tab and discards the old one
  • unload current on a pinned tab: honoured when asked directly
  • idle sweep: enabling auto-unload creates the alarm, the alarm (not a direct call) discards tabs idle past the threshold, the active tab survives
  • a discarded tab reloads when selected (server hit count increases)
  • popup and options pages render, read the saved settings, and the popup button drives the background
  • per-tab exception: a protected tab survives unload-others and the idle sweep, and is discarded once unprotected