UNPKG

@gramercytech/gx-toolkit

Version:
58 lines (51 loc) 2.11 kB
<!DOCTYPE html> <html> <head> <title>Test JavaScript Imports Interception</title> </head> <body> <h1>JavaScript Import Interception Test</h1> <p>Check the Network tab and proxy notifications to see if imports are intercepted.</p> <div id="results"></div> <script type="module"> const results = document.getElementById('results'); function log(message) { const div = document.createElement('div'); div.textContent = `${new Date().toLocaleTimeString()}: ${message}`; results.appendChild(div); } // Test 1: Dynamic import log('Testing dynamic import...'); try { const module = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js'); log('✅ Dynamic import successful'); } catch (error) { log('❌ Dynamic import failed: ' + error.message); } // Test 2: Fetch (for comparison) log('Testing fetch...'); try { const response = await fetch('https://api.github.com/users/octocat'); log('✅ Fetch successful'); } catch (error) { log('❌ Fetch failed: ' + error.message); } // Test 3: Worker (if supported) log('Testing Web Worker...'); try { const workerCode = ` self.postMessage('Worker loaded successfully'); self.close(); `; const blob = new Blob([workerCode], { type: 'application/javascript' }); const worker = new Worker(URL.createObjectURL(blob)); worker.onmessage = () => log('✅ Web Worker successful'); worker.onerror = () => log('❌ Web Worker failed'); } catch (error) { log('❌ Web Worker failed: ' + error.message); } </script> <!-- Test 4: Static import (commented out as it needs a real module file) --> <!-- <script type="module" src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script> --> </body> </html>