working extension tests

This commit is contained in:
Nick Sweeting
2025-12-30 18:30:16 -08:00
parent 42d3fb7025
commit dac6c63bba
2 changed files with 25 additions and 9 deletions

View File

@@ -215,7 +215,25 @@ async function main() {
const manifestPath = path.join(ext.unpacked_path, 'manifest.json');
if (fs.existsSync(manifestPath)) {
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
const manifestName = manifest.name || '';
let manifestName = manifest.name || '';
// Resolve message placeholder (e.g., __MSG_extName__)
if (manifestName.startsWith('__MSG_') && manifestName.endsWith('__')) {
const msgKey = manifestName.slice(6, -2); // Extract key from __MSG_key__
const defaultLocale = manifest.default_locale || 'en';
const messagesPath = path.join(ext.unpacked_path, '_locales', defaultLocale, 'messages.json');
if (fs.existsSync(messagesPath)) {
try {
const messages = JSON.parse(fs.readFileSync(messagesPath, 'utf-8'));
if (messages[msgKey] && messages[msgKey].message) {
manifestName = messages[msgKey].message;
}
} catch (e) {
console.error(`[!] Failed to read messages.json: ${e.message}`);
}
}
}
console.error(`[*] Looking for match: ext.name="${ext.name}" manifest.name="${manifestName}"`);
// Find matching extension from page by exact name match first

View File

@@ -142,13 +142,18 @@ def launch_chrome(env: dict, chrome_dir: Path, crawl_id: str):
)
cdp_url = None
extensions_ready = False
for _ in range(30):
if process.poll() is not None:
stdout, stderr = process.communicate()
raise RuntimeError(f"Chromium failed:\n{stdout}\n{stderr}")
cdp_file = chrome_dir / 'cdp_url.txt'
if cdp_file.exists():
ext_file = chrome_dir / 'extensions.json'
if cdp_file.exists() and not cdp_url:
cdp_url = cdp_file.read_text().strip()
if ext_file.exists():
extensions_ready = True
if cdp_url and extensions_ready:
break
time.sleep(1)
@@ -157,13 +162,6 @@ def launch_chrome(env: dict, chrome_dir: Path, crawl_id: str):
stdout, stderr = process.communicate()
raise RuntimeError(f"CDP URL not found after 30s.\nstdout: {stdout}\nstderr: {stderr}")
# Wait for extensions.json to be written (chrome launch hook parses chrome://extensions)
extensions_file = chrome_dir / 'extensions.json'
for _ in range(15):
if extensions_file.exists():
break
time.sleep(1)
# Print chrome launch hook output for debugging
import select
if hasattr(select, 'poll'):