chromium/third_party/blink/web_tests/accessibility/language-meta-tag-dynamically-changing.html

<!DOCTYPE html>
<html>
  <head>
    <script src="../resources/testharness.js"></script>
    <script src="../resources/testharnessreport.js"></script>
    <!-- The second language in the meta tag should be ignored. -->
    <meta http-equiv="content-language" content="en, es">
  </head>

  <body id="body" role="main">
    <p id="paragraph" lang="pl">Polish.
      <span id="span">Possibly in another language.</span>
    </p>

  <script>
    setup(() => {
      window.axRoot = accessibilityController.rootElement;
      window.axBody = accessibilityController.accessibleElementById('body');
      window.axParagraph = accessibilityController.accessibleElementById('paragraph');
      window.axSpan = accessibilityController.accessibleElementById('span');
    });

    async_test((t) => {
      assert_equals(window.axRoot.language, 'AXLanguage: en',
          'The meta tag has not been changed yet.');
      assert_equals(window.axBody.language, 'AXLanguage: ',
          'Body should not inherit language Blink side.');

      let meta = document.querySelector('meta[http-equiv="content-language"]');
      assert_not_equals(meta, undefined);
      meta.content = 'fr';

      assert_equals(window.axRoot.language, 'AXLanguage: fr',
          'The contents of the meta tag have changed.');
      assert_equals(window.axBody.language, 'AXLanguage: ',
          'Body should not inherit language Blink side.');
      assert_equals(window.axParagraph.language, 'AXLanguage: pl',
          'The lang attribute should take priority over the meta tag.');
      assert_equals(window.axSpan.language, 'AXLanguage: ',
          'Span should not inherit language Blink side.');

      meta.remove();
      let newMeta = document.createElement('meta');
      newMeta.httpEquiv = 'content-language';
      newMeta.content = 'ja';
      document.head.appendChild(newMeta);

      t.step_timeout(() => {
        assert_equals(window.axRoot.language, 'AXLanguage: ja',
            'The whole of the meta tag has been replaced.');
        assert_equals(window.axBody.language, 'AXLanguage: ',
            'Body should not inherit language Blink side.');
        assert_equals(window.axParagraph.language, 'AXLanguage: pl',
            'The lang attribute should take priority over the meta tag.');
        assert_equals(window.axSpan.language, 'AXLanguage: ',
            'Span should not inherit language Blink side.');

        newMeta.remove();
        meta.content = 'en';
        document.head.appendChild(meta);
        t.done();
      }, 0);
    }, 'Tests if dynamically changing the content-language meta tag is picked up by the accessibility component.');
    </script>
  </body>
</html>