https://github.com/web-platform-tests/wpt
Raw File
Tip revision: c77d6e6ae0395fc6d534ad051dca119a775701f2 authored by Joanmarie Diggs on 10 April 2018, 15:51:52 UTC
accname: Updated tests
Tip revision: c77d6e6
radio-input-cancel.html
<!DOCTYPE HTML>
<title>Radio input cancel behavior reverts state</title>
<link rel="author" title="jeffcarp" href="mailto:gcarpenterv@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/#radio-button-state-(type=radio)">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>
"use strict";

test(() => {
  const input = document.createElement("input");
  input.type = "radio";
  document.body.appendChild(input);
  const events = [];

  input.addEventListener("change", () => {
    events.push("change");
  });
  input.addEventListener("click", e => {
    // cancel click event
    e.preventDefault();
    events.push("click");
  });
  input.addEventListener("input", () => {
    events.push("input");
  });

  assert_false(input.checked);

  input.click();

  assert_false(input.checked);

  // only click event called
  assert_array_equals(events, ["click"]);

}, "radio input cancel behavior reverts state");
</script>
back to top