144 lines
5.4 KiB
HTML
144 lines
5.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>PWA Test - SiliconPin</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 600px;
|
|
margin: 50px auto;
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
}
|
|
.test-card {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
margin: 20px 0;
|
|
}
|
|
.status {
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
margin: 10px 0;
|
|
}
|
|
.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
|
|
.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
|
|
.info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
|
|
button {
|
|
background: #007bff;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 20px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
margin: 5px;
|
|
}
|
|
button:hover { background: #0056b3; }
|
|
#results { margin-top: 20px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="test-card">
|
|
<h1>🚀 SiliconPin PWA Test</h1>
|
|
<p>This page tests if your PWA is working correctly.</p>
|
|
|
|
<button onclick="testServiceWorker()">Test Service Worker</button>
|
|
<button onclick="testManifest()">Test Manifest</button>
|
|
<button onclick="testInstallPrompt()">Test Install Prompt</button>
|
|
<button onclick="runAllTests()">Run All Tests</button>
|
|
|
|
<div id="results"></div>
|
|
</div>
|
|
|
|
<script>
|
|
const results = document.getElementById('results');
|
|
|
|
function addResult(message, type = 'info') {
|
|
const div = document.createElement('div');
|
|
div.className = `status ${type}`;
|
|
div.innerHTML = message;
|
|
results.appendChild(div);
|
|
}
|
|
|
|
function clearResults() {
|
|
results.innerHTML = '';
|
|
}
|
|
|
|
async function testServiceWorker() {
|
|
clearResults();
|
|
addResult('🔍 Testing Service Worker...', 'info');
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
try {
|
|
const registration = await navigator.serviceWorker.getRegistration();
|
|
if (registration) {
|
|
addResult('✅ Service Worker is registered and active!', 'success');
|
|
addResult(`📍 Scope: ${registration.scope}`, 'info');
|
|
addResult(`🔄 State: ${registration.active ? registration.active.state : 'No active worker'}`, 'info');
|
|
} else {
|
|
addResult('❌ Service Worker is not registered', 'error');
|
|
}
|
|
} catch (error) {
|
|
addResult(`❌ Service Worker error: ${error.message}`, 'error');
|
|
}
|
|
} else {
|
|
addResult('❌ Service Worker not supported in this browser', 'error');
|
|
}
|
|
}
|
|
|
|
async function testManifest() {
|
|
addResult('🔍 Testing Web App Manifest...', 'info');
|
|
|
|
try {
|
|
const response = await fetch('/manifest.json');
|
|
if (response.ok) {
|
|
const manifest = await response.json();
|
|
addResult('✅ Manifest.json loaded successfully!', 'success');
|
|
addResult(`📱 App Name: ${manifest.name}`, 'info');
|
|
addResult(`🎨 Theme Color: ${manifest.theme_color}`, 'info');
|
|
addResult(`📺 Display Mode: ${manifest.display}`, 'info');
|
|
addResult(`🏠 Start URL: ${manifest.start_url}`, 'info');
|
|
} else {
|
|
addResult('❌ Failed to load manifest.json', 'error');
|
|
}
|
|
} catch (error) {
|
|
addResult(`❌ Manifest error: ${error.message}`, 'error');
|
|
}
|
|
}
|
|
|
|
function testInstallPrompt() {
|
|
addResult('🔍 Testing Install Prompt...', 'info');
|
|
|
|
if (window.matchMedia('(display-mode: standalone)').matches) {
|
|
addResult('✅ App is already installed and running in standalone mode!', 'success');
|
|
} else {
|
|
addResult('📱 App is not installed. Look for install button in browser address bar.', 'info');
|
|
addResult('💡 In Chrome: Click the install icon in the address bar', 'info');
|
|
addResult('💡 In Edge: Click "Install SiliconPin" from the menu', 'info');
|
|
}
|
|
}
|
|
|
|
async function runAllTests() {
|
|
clearResults();
|
|
addResult('🚀 Running all PWA tests...', 'info');
|
|
|
|
await testServiceWorker();
|
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
await testManifest();
|
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
testInstallPrompt();
|
|
|
|
addResult('✅ All tests completed!', 'success');
|
|
}
|
|
|
|
// Auto-run tests on page load
|
|
window.addEventListener('load', () => {
|
|
setTimeout(runAllTests, 1000);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|