UNPKG

@gramercytech/gx-toolkit

Version:
190 lines (169 loc) โ€ข 8.85 kB
<!DOCTYPE html> <html> <head> <title>Mixed Content Proxy Test</title> <style> body { font-family: Arial, sans-serif; padding: 20px; max-width: 800px; } .test-section { margin: 20px 0; padding: 20px; border: 2px solid #ddd; border-radius: 8px; } .error { border-color: #dc3545; background: #fff5f5; } .success { border-color: #28a745; background: #f8fff8; } .warning { border-color: #ffc107; background: #fffbf0; } .info { border-color: #17a2b8; background: #f0f9ff; } .code { background: #e9ecef; padding: 8px; font-family: monospace; margin: 8px 0; word-break: break-all; } .results { background: #f5f5f5; padding: 10px; margin: 10px 0; border-radius: 4px; max-height: 300px; overflow-y: auto; } button { padding: 10px 15px; margin: 5px; cursor: pointer; background: #007bff; color: white; border: none; border-radius: 4px; } .status-indicator { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; } .blocked { background: #dc3545; } .allowed { background: #28a745; } .warning-icon { background: #ffc107; } </style> </head> <body> <h1>๐Ÿ”’ Mixed Content Proxy Test</h1> <div class="test-section info"> <h2>๐ŸŒ Current Page Security</h2> <div id="pageInfo"></div> <div class="code" id="currentUrl"></div> </div> <div class="test-section warning"> <h2>โš ๏ธ Mixed Content Policy</h2> <p><strong>Browser Security Rule:</strong> HTTPS pages cannot make requests to HTTP endpoints</p> <ul> <li><span class="status-indicator blocked"></span><strong>BLOCKED:</strong> HTTPS โ†’ HTTP (Subresources)</li> <li><span class="status-indicator warning-icon"></span><strong>WARNING:</strong> HTTPS โ†’ HTTP (Navigation)</li> <li><span class="status-indicator allowed"></span><strong>ALLOWED:</strong> HTTPS โ†’ HTTPS</li> <li><span class="status-indicator allowed"></span><strong>ALLOWED:</strong> HTTP โ†’ HTTP</li> </ul> </div> <div class="test-section"> <h2>๐Ÿงช Mixed Content Tests</h2> <button onclick="testHttpsToHttp()">Test HTTPS โ†’ HTTP Fetch</button> <button onclick="testHttpsToHttps()">Test HTTPS โ†’ HTTPS Fetch</button> <button onclick="testImageLoad()">Test HTTP Image Load</button> <button onclick="testScriptLoad()">Test HTTP Script Load</button> <div id="testResults" class="results"></div> </div> <div class="test-section error"> <h2>โŒ Common Scenarios That Fail</h2> <div class="code"> # Page: https://example.com<br> # Proxy rule: api.service.com โ†’ http://my-proxy.local:8080<br> # Result: โŒ BLOCKED - Mixed content violation </div> </div> <div class="test-section success"> <h2>โœ… Working Solutions</h2> <h3>Option 1: Use HTTPS for Proxy Target</h3> <div class="code"> # Proxy rule: api.service.com โ†’ https://my-proxy.com<br> # Result: โœ… WORKS - Both HTTPS </div> <h3>Option 2: Setup HTTPS on Local Proxy</h3> <div class="code"> # Use mkcert or similar to create local HTTPS<br> # Proxy rule: api.service.com โ†’ https://localhost:8443<br> # Result: โœ… WORKS - HTTPS to HTTPS </div> <h3>Option 3: Browser Flags (Development Only)</h3> <div class="code"> # Chrome: --disable-web-security --disable-features=VizDisplayCompositor<br> # Firefox: security.mixed_content.block_active_content = false<br> # Result: โš ๏ธ WORKS but INSECURE </div> </div> <div class="test-section info"> <h2>๐Ÿ”ง Extension Capabilities</h2> <table style="width: 100%; border-collapse: collapse;"> <tr style="background: #f8f9fa;"> <th style="border: 1px solid #ddd; padding: 8px;">Request Type</th> <th style="border: 1px solid #ddd; padding: 8px;">HTTPS โ†’ HTTP</th> <th style="border: 1px solid #ddd; padding: 8px;">Extension Override</th> </tr> <tr> <td style="border: 1px solid #ddd; padding: 8px;">Main Frame Navigation</td> <td style="border: 1px solid #ddd; padding: 8px;">โš ๏ธ Warning shown</td> <td style="border: 1px solid #ddd; padding: 8px;">โœ… Can redirect</td> </tr> <tr> <td style="border: 1px solid #ddd; padding: 8px;">fetch() / XHR</td> <td style="border: 1px solid #ddd; padding: 8px;">โŒ Blocked</td> <td style="border: 1px solid #ddd; padding: 8px;">โŒ Still blocked</td> </tr> <tr> <td style="border: 1px solid #ddd; padding: 8px;">Images / CSS</td> <td style="border: 1px solid #ddd; padding: 8px;">โŒ Blocked</td> <td style="border: 1px solid #ddd; padding: 8px;">โŒ Still blocked</td> </tr> <tr> <td style="border: 1px solid #ddd; padding: 8px;">Scripts / Modules</td> <td style="border: 1px solid #ddd; padding: 8px;">โŒ Blocked</td> <td style="border: 1px solid #ddd; padding: 8px;">โŒ Still blocked</td> </tr> </table> </div> <script> function log(message, type = 'info') { const results = document.getElementById('testResults'); const timestamp = new Date().toLocaleTimeString(); const icon = type === 'error' ? 'โŒ' : type === 'success' ? 'โœ…' : type === 'warning' ? 'โš ๏ธ' : 'โ„น๏ธ'; results.innerHTML += `<div>${timestamp} ${icon} ${message}</div>`; } function updatePageInfo() { const protocol = window.location.protocol; const isHttps = protocol === 'https:'; const pageInfo = document.getElementById('pageInfo'); const currentUrl = document.getElementById('currentUrl'); pageInfo.innerHTML = ` <strong>Protocol:</strong> ${protocol} ${isHttps ? '๐Ÿ”’ Secure' : '๐Ÿ”“ Insecure'}<br> <strong>Mixed Content Policy:</strong> ${isHttps ? 'โœ… Active' : 'โž– Not applicable'} `; currentUrl.textContent = window.location.href; } async function testHttpsToHttp() { log('Testing HTTPS page โ†’ HTTP endpoint...'); try { const response = await fetch('http://httpbin.org/get?test=mixed-content'); log(`โœ… Request succeeded: ${response.status}`, 'success'); } catch (error) { if (error.message.includes('mixed content')) { log(`โŒ Mixed content blocked: ${error.message}`, 'error'); } else { log(`โŒ Request failed: ${error.message}`, 'error'); } } } async function testHttpsToHttps() { log('Testing HTTPS page โ†’ HTTPS endpoint...'); try { const response = await fetch('https://httpbin.org/get?test=secure'); log(`โœ… Request succeeded: ${response.status}`, 'success'); } catch (error) { log(`โŒ Request failed: ${error.message}`, 'error'); } } function testImageLoad() { log('Testing HTTP image load...'); const img = new Image(); img.onload = () => log('โœ… HTTP image loaded successfully', 'success'); img.onerror = () => log('โŒ HTTP image blocked by mixed content policy', 'error'); img.src = 'http://httpbin.org/image/png?test=image'; } function testScriptLoad() { log('Testing HTTP script load...'); const script = document.createElement('script'); script.onload = () => log('โœ… HTTP script loaded successfully', 'success'); script.onerror = () => log('โŒ HTTP script blocked by mixed content policy', 'error'); script.src = 'http://httpbin.org/base64/Y29uc29sZS5sb2coJ0hUVFAgc2NyaXB0IGxvYWRlZCcpOw=='; document.head.appendChild(script); } // Initialize page updatePageInfo(); // Show initial warning if on HTTPS if (window.location.protocol === 'https:') { log('โš ๏ธ This is an HTTPS page. HTTP requests will be blocked by mixed content policy.', 'warning'); } else { log('โ„น๏ธ This is an HTTP page. No mixed content restrictions apply.', 'info'); } </script> </body> </html>