chromium/third_party/blink/web_tests/http/tests/security/document-domain-canonicalizes.html

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

<script>
// This test depends on non-compliant behavior of the URL.
// The test assumes that '*' character is escaped, but that
// should be fixed. See https://crbug.com/1416013.
if (document.location.hostname == "127.0.0.1") {
  document.location.hostname = "sub*.subdomain.example.test";
} else {
  test(function() {
      // Properly canonicalize the host.
      assert_equals(document.location.hostname, "sub%2A.subdomain.example.test");

      document.domain = 'EXAMPLE.TEST';
      assert_equals(document.domain, 'example.test');

      document.domain = 'subdomain.eXamPle.tEst';
      assert_equals(document.domain, 'subdomain.example.test');

      document.domain = 'sub*.subdomain.example.test';
      assert_equals(document.domain, 'sub%2A.subdomain.example.test');

  }, 'document.domain goes through proper canonicalization.');
}
</script>