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