forked from icd/rentgen
Changed test from artificial computation ((17*2)+3=37) to real-world functionality testing: counting third-party domains shown in badge. Test flow: 1. Visit news.ycombinator.com → verify badge = 0 (no trackers) 2. Visit pudelek.pl → verify badge > 0 (has trackers) Changes: - background.ts: handler returns badgeCount from getClustersForOrigin() - test-content-script.js: sends origin, stores badgeCount in DOM - test-lib.js: testBadgeCount() replaces testBackgroundComputation() - test_verify.py: tests two real sites instead of math computation This tests actual Rentgen functionality: third-party domain detection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { init, getMemory } from "./memory";
|
|
|
|
// Use global browser object directly (available in extension context)
|
|
declare const browser: any;
|
|
declare const ENABLE_TESTS: boolean;
|
|
|
|
init();
|
|
|
|
// Test verification handler for Marionette tests
|
|
// Tests real Rentgen functionality: counting third-party domains
|
|
if (ENABLE_TESTS) {
|
|
browser.runtime.onMessage.addListener((message: any, sender: any, sendResponse: any) => {
|
|
if (message.type === 'RENTGEN_TEST_VERIFICATION') {
|
|
// Get the origin from message (sent by content script)
|
|
const origin = message.origin;
|
|
|
|
// Access the memory to get clusters for this origin
|
|
const memory = getMemory();
|
|
const clusters = memory.getClustersForOrigin(origin);
|
|
const badgeCount = Object.keys(clusters).length;
|
|
|
|
// Send back the badge count (number of third-party domains)
|
|
const response = {
|
|
success: true,
|
|
badgeCount: badgeCount,
|
|
origin: origin,
|
|
clusterIds: Object.keys(clusters),
|
|
backgroundTimestamp: Date.now()
|
|
};
|
|
|
|
sendResponse(response);
|
|
return true; // Keep channel open for async response
|
|
}
|
|
});
|
|
}
|