',
'
',
'',
'
Click me
',
'Link',
'Normal text bold and italic',
'Safe content
'
];
console.log('Testing XSS Protection:');
testCases.forEach((testCase, index) => {
console.log(`\nTest ${index + 1}: ${testCase}`);
console.log('escapeHtml:', escapeHtml(testCase));
console.log('sanitizeHtml:', sanitizeHtml(testCase));
console.log('sanitizeUserInput:', sanitizeUserInput(testCase));
});
// DOM test
const testDiv = document.getElementById('test');
const dangerousContent = 'Safe content';
// Test safeSetInnerHTML
if (window.safeSetInnerHTML) {
window.safeSetInnerHTML(testDiv, dangerousContent, true);
console.log('DOM test completed - check if script executed (it should not)');
}
});
XSS Protection Test
Check browser console for test results.