-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-servers.html
More file actions
49 lines (44 loc) · 1.88 KB
/
test-servers.html
File metadata and controls
49 lines (44 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<title>Server Test</title>
</head>
<body>
<h1>Server Test</h1>
<div id="results"></div>
<script>
// Test localStorage functionality
function testLocalStorage() {
const results = document.getElementById('results');
const port = window.location.port;
try {
// Test writing to localStorage
const testData = [{ id: 'test', name: 'Test Rule', enabled: true }];
localStorage.setItem('interzept-rules', JSON.stringify(testData));
// Test reading from localStorage
const saved = localStorage.getItem('interzept-rules');
const parsed = saved ? JSON.parse(saved) : [];
results.innerHTML = `
<h2>Server on Port ${port}</h2>
<p><strong>localStorage Write:</strong> ${localStorage.setItem ? 'SUCCESS' : 'FAILED'}</p>
<p><strong>localStorage Read:</strong> ${saved ? 'SUCCESS' : 'FAILED'}</p>
<p><strong>Data Retrieved:</strong> ${JSON.stringify(parsed, null, 2)}</p>
<p><strong>Rules Count:</strong> ${parsed.length}</p>
<hr>
<h3>All localStorage Keys:</h3>
<ul>
${Object.keys(localStorage).map(key => `<li>${key}: ${localStorage.getItem(key)?.substring(0, 100)}...</li>`).join('')}
</ul>
`;
} catch (error) {
results.innerHTML = `
<h2>Server on Port ${port}</h2>
<p style="color: red;"><strong>ERROR:</strong> ${error.message}</p>
`;
}
}
// Run test when page loads
window.onload = testLocalStorage;
</script>
</body>
</html>