Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /uievents/order-of-events/mouse-events/click-cancel.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Default action is canceled if the click event is canceled.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
</head>
<body>
<input type="checkbox" id="checkbox">Check me!<br>
<button type="button" id="button">Button</button>
<script>
async_test(function(t) {
var box_clicked = false;
var box = document.getElementById("checkbox");
box.addEventListener("click", function(event) {
box_clicked = true;
event.preventDefault();
});
var button = document.getElementById("button");
button.addEventListener("click", t.step_func_done(function() {
assert_true(box_clicked);
assert_false(box.checked);
}));
test_driver.click(box).then(function() {
return test_driver.click(button);
}).catch(t.unreached_func("click failed"));
});
</script>
</body>
</html>