chromium/third_party/blink/web_tests/external/wpt/html/semantics/disabled-elements/fieldset-event-propagation.tentative.html

<!DOCTYPE html>
<link rel=author href="mailto:[email protected]">
<link rel=help href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-disabled">
<link rel=help href="https://github.com/whatwg/html/issues/5886#issuecomment-1460425364">
<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>
<script src="/resources/testdriver-actions.js"></script>

<div id=target1parent>
  <fieldset disabled id=target1fieldset>
    <div id=target1child>hello world</div>
  </fieldset>
</div>

<div id=target2parent>
  <fieldset disabled id=target2fieldset>hello world</fieldset>
</div>

<script>
  const clickers = {
    "native click": target => test_driver.click(target),
    "click()": target => target.click(),
  };

  for (const [clickerName, clicker] of Object.entries(clickers)) {
    promise_test(async () => {
      let target1parentClicked = false;
      let target1childClicked = false;
      let target1fieldsetClicked = false;
      target1parent.onclick = () => target1parentClicked = true;
      target1child.onclick = () => target1childClicked = true;
      target1fieldset.onclick = () => target1fieldsetClicked = true;

      await clicker(target1child);

      assert_true(target1parentClicked, 'The parent of the fieldset should receive a click event.');
      assert_true(target1childClicked, 'The child of the fieldset should receive a click event.');
      assert_true(target1fieldsetClicked, 'The fieldset element should receive a click event.');
    }, `Disabled fieldset elements should not prevent click event propagation from ${clickerName}`);

    promise_test(async () => {
      let target2parentClicked = false;
      let target2fieldsetClicked = false;
      target2parent.onclick = () => target2parentClicked = true;
      target2fieldset.onclick = () => target2fieldsetClicked = true;

      await clicker(target2fieldset);

      assert_true(target2parentClicked, 'The parent of the fieldset should receive a click event.');
      assert_true(target2fieldsetClicked, 'The fieldset element should receive a click event.');
    }, `Disabled fieldset elements should not block click events from ${clickerName}.`);
  }
</script>