diff --git a/scripts/functional_test.sh b/scripts/functional_test.sh index 6ac07e0..4580ec1 100644 --- a/scripts/functional_test.sh +++ b/scripts/functional_test.sh @@ -1,14 +1,14 @@ #!/bin/bash # -# functional_test.sh - DEFINITYWNY test działania extensiona +# functional_test.sh - DEFINITIVE test of extension operation # -# Ten skrypt wykonuje FAKTYCZNY test funkcjonalny: -# 1. Uruchamia Firefox z extensionem (przez web-ext run) -# 2. Ładuje stronę testową która zawiera third-party requesty -# 3. Sprawdza czy extension przechwycił requesty +# This script performs an ACTUAL functional test: +# 1. Starts Firefox with extension (via web-ext run) +# 2. Loads test page containing third-party requests +# 3. Checks if extension intercepted requests # -# To jest jedyny pewny sposób weryfikacji w środowisku Docker/headless, -# ponieważ console.error z background page nie trafia do web-ext stdout. +# This is the only reliable way to verify in Docker/headless environment, +# because console.error from background page doesn't reach web-ext stdout. # set -e @@ -19,7 +19,7 @@ echo "========================================" echo "" # Start Xvfb -echo "[1/5] Uruchamianie Xvfb..." +echo "[1/5] Starting Xvfb..." Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 & XVFB_PID=$! export DISPLAY=:99 @@ -28,18 +28,18 @@ echo "✓ Xvfb PID: $XVFB_PID" # Start Firefox with extension echo "" -echo "[2/5] Uruchamianie Firefox z extensionem..." +echo "[2/5] Starting Firefox with extension..." timeout 60s npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log & WEBEXT_PID=$! echo "✓ web-ext PID: $WEBEXT_PID" # Wait for extension to install echo "" -echo "[3/5] Czekam na instalację extensiona..." +echo "[3/5] Waiting for extension installation..." INSTALLED=false for i in {1..30}; do if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then - echo "✓ Extension zainstalowany!" + echo "✓ Extension installed!" INSTALLED=true break fi @@ -47,7 +47,7 @@ for i in {1..30}; do done if [ "$INSTALLED" = false ]; then - echo "✗ Extension nie zainstalował się w czasie 30s" + echo "✗ Extension failed to install within 30s" exit 1 fi @@ -60,18 +60,18 @@ sleep 3 # Check for JavaScript errors echo "" -echo "[4/5] Sprawdzanie błędów JavaScript..." +echo "[4/5] Checking for JavaScript errors..." if grep -i "JavaScript error.*background.js\|SyntaxError\|ReferenceError" /tmp/web-ext.log 2>/dev/null | grep -v "BackupService\|RSLoader"; then - echo "✗✗✗ ZNALEZIONO BŁĘDY W KODZIE EXTENSIONA!" + echo "✗✗✗ FOUND ERRORS IN EXTENSION CODE!" exit 1 else - echo "✓ Brak błędów składniowych w background.js" + echo "✓ No syntax errors in background.js" fi # Functional test: Load a test page with third-party resources echo "" -echo "[5/5] TEST FUNKCJONALNY: Ładowanie strony testowej..." -echo "Próba załadowania example.com (która ma third-party requesty)..." +echo "[5/5] FUNCTIONAL TEST: Loading test page..." +echo "Attempting to load example.com (which has third-party requests)..." # Use firefox-bin to load a page in the running Firefox instance # This will trigger webRequest listeners if extension is working @@ -79,51 +79,51 @@ timeout 10s bash -c " # Try to use Firefox remote debugging to navigate # Simple test: just verify Firefox is responsive if ps -p $WEBEXT_PID > /dev/null; then - echo '✓ Firefox proces nadal działa' + echo '✓ Firefox process still running' else - echo '✗ Firefox proces zakończył się' + echo '✗ Firefox process terminated' exit 1 fi " || true # Final verification: Check logs for any evidence of extension activity echo "" -echo "Sprawdzanie aktywności extensiona w logach..." +echo "Checking for extension activity in logs..." # Look for webRequest related logs or extension activity if grep -E "webRequest|rentgen|Watching.*for changes" /tmp/web-ext.log 2>/dev/null | tail -5; then echo "" - echo "✓ Extension jest aktywny (watching for changes)" + echo "✓ Extension is active (watching for changes)" else - echo "⚠ Nie znaleziono logów aktywności extensiona" + echo "⚠ Did not find extension activity logs" fi # Final verdict echo "" echo "========================================" -echo " WYNIK TESTU" +echo " TEST RESULTS" echo "========================================" -echo "✓ Extension zainstalowany poprawnie" -echo "✓ Firefox uruchomiony z extensionem" -echo "✓ Brak błędów JavaScript w background.js" -echo "✓ Extension monitoruje zmiany (aktywny)" +echo "✓ Extension installed correctly" +echo "✓ Firefox running with extension" +echo "✓ No JavaScript errors in background.js" +echo "✓ Extension monitoring changes (active)" echo "" -echo "⚠ OGRANICZENIE: console.error z background" -echo " page nie pojawia się w web-ext logs" -echo " (to normalne ograniczenie Firefoksa)" +echo "⚠ LIMITATION: console.error from background" +echo " page doesn't appear in web-ext logs" +echo " (this is a normal Firefox limitation)" echo "" -echo "PRZYJĘTE ZAŁOŻENIE: Extension działa jeśli:" -echo " - Zainstalował się bez błędów" -echo " - Nie ma błędów JS w logach" -echo " - Firefox pozostaje uruchomiony" +echo "ASSUMPTION: Extension works if:" +echo " - Installed without errors" +echo " - No JS errors in logs" +echo " - Firefox remains running" echo "========================================" # Keep Firefox running for a moment sleep 5 echo "" -echo "Test zakończony. Firefox będzie działał przez 60s..." -echo "Naciśnij Ctrl+C aby zatrzymać." +echo "Test completed. Firefox will run for 60s..." +echo "Press Ctrl+C to stop." # Wait for web-ext to finish or timeout wait $WEBEXT_PID || true diff --git a/scripts/verify_extension_code.sh b/scripts/verify_extension_code.sh index d7f774a..5c1156f 100644 --- a/scripts/verify_extension_code.sh +++ b/scripts/verify_extension_code.sh @@ -1,29 +1,29 @@ #!/bin/bash # -# verify_extension_code.sh - Weryfikuje czy kod extensiona faktycznie się wykonał +# verify_extension_code.sh - Verifies that extension code actually executed # -# Problem: console.error z background page nie trafia do web-ext stdout (ograniczenie Firefoksa) -# Rozwiązanie: Użyj Firefox Remote Debugging Protocol żeby sprawdzić stan extensiona +# Problem: console.error from background page doesn't reach web-ext stdout (Firefox limitation) +# Solution: Use Firefox Remote Debugging Protocol to check extension state # -# Ten skrypt: -# 1. Łączy się z Firefox Remote Debugging Protocol -# 2. Wykonuje JavaScript w kontekście background page -# 3. Sprawdza czy obiekt Memory istnieje (dowód że init() się wykonał) +# This script: +# 1. Connects to Firefox Remote Debugging Protocol +# 2. Executes JavaScript in background page context +# 3. Checks if Memory object exists (proof that init() executed) # set -e echo "==========================================" -echo "Weryfikacja wykonania kodu extensiona..." +echo "Verifying extension code execution..." echo "==========================================" # Wait for web-ext.log to have debugger port -echo "Czekam na Firefox debugger port..." +echo "Waiting for Firefox debugger port..." for i in {1..30}; do if [ -f /tmp/web-ext.log ]; then PORT=$(grep -oP "start-debugger-server \K[0-9]+" /tmp/web-ext.log | head -1) if [ -n "$PORT" ]; then - echo "✓ Znaleziono debugger port: $PORT" + echo "✓ Found debugger port: $PORT" break fi fi @@ -31,8 +31,8 @@ for i in {1..30}; do done if [ -z "$PORT" ]; then - echo "✗ BŁĄD: Nie znaleziono portu debuggera w logach" - echo "Extension może się nie załadować poprawnie" + echo "✗ ERROR: Could not find debugger port in logs" + echo "Extension may not load correctly" exit 1 fi @@ -41,7 +41,7 @@ sleep 3 # Try to connect to debugger and check if Memory object exists echo "" -echo "Próba połączenia z Remote Debugging Protocol..." +echo "Attempting to connect to Remote Debugging Protocol..." # Use netcat to send raw RDP commands # RDP uses JSON-RPC like protocol @@ -52,31 +52,31 @@ echo "Próba połączenia z Remote Debugging Protocol..." # Simple test: check if port is open if timeout 2 bash -c "echo > /dev/tcp/127.0.0.1/$PORT" 2>/dev/null; then - echo "✓ Debugger port $PORT jest otwarty" + echo "✓ Debugger port $PORT is open" else - echo "✗ Nie można połączyć się z portem $PORT" + echo "✗ Cannot connect to port $PORT" exit 1 fi # Check if we can find evidence in logs that extension is working echo "" -echo "Sprawdzanie logów web-ext..." +echo "Checking web-ext logs..." # Check if extension was installed successfully if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log; then - echo "✓ Extension zainstalowany: rentgen@internet-czas-dzialac.pl" + echo "✓ Extension installed: rentgen@internet-czas-dzialac.pl" else - echo "✗ Brak potwierdzenia instalacji extensiona" + echo "✗ No confirmation of extension installation" exit 1 fi # Check if there are any JavaScript errors from extension if grep -i "JavaScript error.*rentgen\|JavaScript error.*background.js" /tmp/web-ext.log 2>/dev/null; then - echo "✗ ZNALEZIONO BŁĘDY JAVASCRIPT W EXTENSIONIE!" + echo "✗ FOUND JAVASCRIPT ERRORS IN EXTENSION!" grep -i "JavaScript error.*rentgen\|JavaScript error.*background.js" /tmp/web-ext.log | head -5 exit 1 else - echo "✓ Brak błędów JavaScript z extensiona w logach" + echo "✓ No JavaScript errors from extension in logs" fi # Final verdict: if extension installed without errors, assume it's working @@ -84,16 +84,16 @@ fi # Functional testing would require triggering actual HTTP requests echo "" echo "==========================================" -echo "✓✓✓ WERYFIKACJA ZAKOŃCZONA SUKCESEM ✓✓✓" +echo "✓✓✓ VERIFICATION COMPLETED SUCCESSFULLY ✓✓✓" echo "==========================================" -echo "Extension został zainstalowany i nie wykryto błędów" +echo "Extension was installed and no errors detected" echo "" -echo "UWAGA: console.error z background page nie pojawia się w logach" -echo " (to ograniczenie Firefoksa, a nie błąd extensiona)" +echo "NOTE: console.error from background page doesn't appear in logs" +echo " (this is a Firefox limitation, not an extension bug)" echo "" -echo "Aby DEFINITYWNIE zweryfikować działanie:" -echo " 1. Użyj Remote Debugging Protocol do query Memory object" -echo " 2. Lub załaduj stronę testową i sprawdź czy requesty są przechwytywane" +echo "To DEFINITIVELY verify operation:" +echo " 1. Use Remote Debugging Protocol to query Memory object" +echo " 2. Or load a test page and check if requests are intercepted" echo "==========================================" exit 0 diff --git a/scripts/verify_extension_working.sh b/scripts/verify_extension_working.sh index 3baf240..9de44fa 100644 --- a/scripts/verify_extension_working.sh +++ b/scripts/verify_extension_working.sh @@ -1,14 +1,14 @@ #!/bin/bash # -# verify_extension_working.sh - Weryfikuje czy extension faktycznie przechwytuje requesty +# verify_extension_working.sh - Verifies that extension actually intercepts requests # -# Test wykonuje HTTP request wewnątrz Firefoksa i sprawdza czy extension go przechwycił -# poprzez Badge API (licznik domen na ikonie extensiona) +# Test performs HTTP request inside Firefox and checks if extension intercepted it +# via Badge API (domain counter on extension icon) # set -e -echo "Uruchamianie Firefoksa z extensionem..." +echo "Starting Firefox with extension..." Xvfb :99 -screen 0 1024x768x24 & XVFB_PID=$! export DISPLAY=:99 @@ -19,10 +19,10 @@ npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log & WEBEXT_PID=$! # Wait for extension installation -echo "Czekam na instalację extensiona..." +echo "Waiting for extension installation..." for i in {1..30}; do if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then - echo "✓ Extension zainstalowany" + echo "✓ Extension installed" break fi sleep 1 @@ -34,8 +34,8 @@ sleep 3 # Try to trigger a request that extension should intercept # We'll use Firefox to load a simple webpage echo "" -echo "Testowanie czy extension przechwytuje requesty..." -echo "Próba załadowania example.com w Firefox..." +echo "Testing if extension intercepts requests..." +echo "Attempting to load example.com in Firefox..." # Use Firefox's remote debugging protocol to open a URL # This should trigger webRequest listeners if extension is working @@ -52,13 +52,13 @@ timeout 10s bash -c ' # Check logs for evidence of request interception echo "" -echo "Sprawdzanie logów..." +echo "Checking logs..." if grep -i "example.com" /tmp/web-ext.log 2>/dev/null; then - echo "✓✓✓ SUCCESS: Request do example.com został wykryty!" - echo "✓✓✓ Extension FAKTYCZNIE przechwytuje requesty!" + echo "✓✓✓ SUCCESS: Request to example.com was detected!" + echo "✓✓✓ Extension IS ACTUALLY intercepting requests!" exit 0 else - echo "✗✗✗ BRAK DOWODÓW że extension przechwytuje requesty" - echo "Extension może być zainstalowany ale KOD może się nie wykonywać" + echo "✗✗✗ NO EVIDENCE that extension intercepts requests" + echo "Extension may be installed but CODE may not be executing" exit 1 fi