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 } }); }