fix: test suite CSP compatibility for Firefox extension pages

Replace inline onclick handlers with addEventListener (Firefox
extension CSP blocks inline event handlers). Show loading state
and test count on page load.

https://claude.ai/code/session_01KF4i7Ra7zCEDskxDBaNtcT
This commit is contained in:
Claude
2026-03-28 18:13:17 +00:00
parent 9ecd532a71
commit ed9419f04b
+14 -5
View File
@@ -29,8 +29,8 @@
Load this page as an extension page (or inject via dev console on the Options page).<br> Load this page as an extension page (or inject via dev console on the Options page).<br>
Tests exercise sync, encryption, storage, auto-redact, and domain management. Tests exercise sync, encryption, storage, auto-redact, and domain management.
</p> </p>
<button class="primary" onclick="runAllTests()">Run All Tests</button> <button class="primary" id="btnRunTests">Run All Tests</button>
<button onclick="document.getElementById('results').innerHTML=''">Clear</button> <button id="btnClear">Clear</button>
<div id="results" style="margin-top:16px"></div> <div id="results" style="margin-top:16px"></div>
<div id="summary"></div> <div id="summary"></div>
@@ -485,7 +485,8 @@
// RUN ALL // RUN ALL
// ============================================================ // ============================================================
window.runAllTests = async function() { async function runAllTests() {
document.getElementById('results').innerHTML = '<p style="color:#6b7280">Running tests...</p>';
const outcomes = []; const outcomes = [];
for (const t of results) { for (const t of results) {
try { try {
@@ -497,10 +498,18 @@
} }
} }
renderResults(outcomes); renderResults(outcomes);
}; }
// Auto-register tests on load // Wire up buttons (CSP blocks inline onclick)
document.getElementById('btnRunTests').addEventListener('click', runAllTests);
document.getElementById('btnClear').addEventListener('click', () => {
document.getElementById('results').innerHTML = '';
document.getElementById('summary').textContent = '';
});
// Show ready state
console.log(`[Silent Send Tests] ${results.length} tests registered. Click "Run All Tests" to start.`); console.log(`[Silent Send Tests] ${results.length} tests registered. Click "Run All Tests" to start.`);
document.getElementById('results').innerHTML = `<p style="color:#6b7280">${results.length} tests loaded. Click "Run All Tests" to start.</p>`;
</script> </script>
</body> </body>
</html> </html>