<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html lang="en">
 <head>
  <title>setRequestHeader at odd times</title>
 </head>
 <body>
  <p>FAIL: Script did not run.</p>
  <script type="text/javascript">
   if (window.testRunner)
     testRunner.dumpAsText();

   var p = document.getElementsByTagName('p')[0];
   p.firstChild.data = 'FAIL: Test script did not finish.';
   window.onerror = function (error, file, line) { p.firstChild.data = 'ERROR: ' + error + ' (line ' + line + ')'; }
   if (!window.XMLHttpRequest)
     window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
   var r = new XMLHttpRequest;
   r.open('GET', '003-test.cgi', false);
   r.setRequestHeader('X-Test-Header', 'FAIL1');
   r.send(null);
   r.open('GET', '003-test.cgi', false);
   r.setRequestHeader('X-Test-Header', 'FAIL2');
   r.open('GET', '003-test.cgi', false);
   r.setRequestHeader('X-Test-Header', 'TEST3');
   r.send(null);
   if (r.responseText == 'RESULT:[TEST3]') {
     p.firstChild.data = 'PASS';
   } else {
     p.firstChild.data = 'FAIL (' + r.responseText + ')';
   }
  </script>
 </body>
</html>
