Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=author href="mailto:falken@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
dialog {
width: 50px;
}
</style>
<button>Click me</button>
<div id="div">Click me too</div>
<dialog></dialog>
<script>
test(() => {
dialog = document.querySelector('dialog');
dialog.showModal();
const button = document.querySelector('button');
const div = document.getElementById('div');
let clicked = false;
[button, div].forEach(function(element) {
element.addEventListener('click', () => clicked = true);
clicked = false;
element.click();
assert_true(clicked, 'Calling click() on ' + element.tagName);
clicked = false;
element.dispatchEvent(new Event('click'));
assert_true(clicked, 'Calling dispatchEvent() on ' + element.tagName);
});
}, 'Test that inert nodes still get programmatic click events');
</script>