chromium/third_party/blink/web_tests/accessibility/multiple-text-nodes.html

<!doctype html>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>

  <!-- No space in final name; it is redundant at the end of the button -->
  <button id="buttonA">before<span id="spanA1"></span> <span id="spanA2"></span>
    </button>

  <!-- Space in final name, to separate "before" and "after" -->
  <button id="buttonB">before<span id="spanB1"></span> <span id="spanB2"></span>after
    </button>

<script>
test((t) => {
  // Remove the spans, so the button will have multiple contiguous text children
  buttonA.removeChild(spanA1);
  buttonA.removeChild(spanA2);
  var axButton = accessibilityController.accessibleElementById('buttonA');
  assert_equals(axButton.name, "before");
}, "Multiple text node children do not result in duplicated text");

test((t) => {
  // Remove the spans, so the button will have multiple contiguous text children
  buttonB.removeChild(spanB1);
  buttonB.removeChild(spanB2);
  var axButton = accessibilityController.accessibleElementById('buttonB');
  assert_equals(axButton.name, "before after");
}, "Removing text nodes does not result in duplicated text but keeps necessary space");

</script>
</body>
</html>