54 lines
1.5 KiB
HTML
54 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>SharedWorker importScripts Test</title>
|
|
<style>
|
|
body { font-family: sans-serif; background: #1a1a2e; color: #eee; padding: 40px; }
|
|
h1 { margin-bottom: 10px; }
|
|
.pass { color: #0f0; }
|
|
.fail { color: #f00; }
|
|
.info { color: #ff0; }
|
|
#output { background: #16213e; padding: 16px; border-radius: 8px; margin-top: 20px; font-family: monospace; white-space: pre-wrap; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>🔄 SharedWorker importScripts Test</h1>
|
|
<p>Tests whether <code>importScripts()</code> works inside a SharedWorker loaded from <code>local://</code>.</p>
|
|
|
|
<div id="output">Running tests...</div>
|
|
|
|
<script>
|
|
var output = document.getElementById('output');
|
|
function log(msg, cls) {
|
|
output.innerHTML += '<span class="' + (cls || '') + '">' + msg + '</span>\n';
|
|
}
|
|
|
|
log('=== importScripts Test ===\n', 'info');
|
|
|
|
try {
|
|
var worker = new SharedWorker('shared-worker-import-test.js');
|
|
log('✓ SharedWorker constructor succeeded', 'pass');
|
|
|
|
worker.port.onmessage = function(e) {
|
|
log('✓ Received: ' + e.data, 'pass');
|
|
};
|
|
|
|
worker.port.onerror = function(e) {
|
|
log('✗ Worker error: ' + (e.message || 'unknown'), 'fail');
|
|
};
|
|
|
|
worker.port.postMessage('ping');
|
|
|
|
setTimeout(function() {
|
|
log('\n--- Done ---', 'info');
|
|
}, 3000);
|
|
|
|
} catch (e) {
|
|
log('✗ SharedWorker constructor threw: ' + e.message, 'fail');
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|