blob: 800907a4edf0352a9dd63d98aa0eacfd42e7dbb5 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
window.expectSuccess = t.step_func_done(function (el) {
assert_equals(el, document.querySelector('#pass'));
});
window.addEventListener('load', t.step_func(function () {
document.querySelector('#pass').click();
}));
}, 'Inline event handlers whitelisted by the policy should fire.');
async_test(function (t) {
window.expectFailure = t.unreached_func("Handler should not execute.");
document.addEventListener('securitypolicyviolation', t.step_func_done(function (e) {
assert_equals(e.target, document.querySelector('#fail'));
}));
window.addEventListener('load', t.step_func(function () {
document.querySelector('#fail').click();
}));
}, 'Inline event handlers not whitelisted by the policy should generate error events.');
</script>
<meta http-equiv="Content-Security-Policy" content="script-src 'sha256-nhtYaXCssBJTThiDLYewspQYue9tisulEwJ3nTJKcMI=' 'unsafe-hashes'">
</head>
<body>
<button id="pass" onclick="expectSuccess(this)"></button>
<button id="fail" onclick="expectFailure(this)"></button>
</body>
</html>