chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/serialize-document.html

<html>
   <head>
   </head>

   <body>
   <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=18421">bug 18421</a>:
   XMLHttpRequest does not properly encode &amp; and &lt; in outgoing messages.</p>
   </body>
   <script type="text/javascript">
       if (window.testRunner)
          testRunner.dumpAsText();

       // Create a new document
       var dom = document.implementation.createDocument("","", null);

       // Create the root node
       var root = dom.appendChild(dom.createElement("foo"));

       // Add an attribute
       root.setAttribute("foo", "a&b");

       // Add a text node
       var txt = dom.createTextNode("a&b");

       // Append it
       root.appendChild(txt);

       // Create the XHR object
       var xhr = new XMLHttpRequest();
       xhr.open("POST", "resources/post-echo.cgi", false);
       xhr.send(dom);

       if (xhr.responseText == '<foo foo="a&amp;b">a&amp;b</foo>')
          document.body.innerHTML +="PASS";
       else
          document.body.innerHTML +="FAIL: <xmp>" + xhr.responseText + "</xmp>";
   </script>

</html>