title: How to test XMLHttpRequest with Jasmine
body: <p>How can I test the onreadystatechange on XMLHttpRequest or pure Javascript AJAX without jQuery? I'm doing this because I'm developing Firefox extension. I guess I have to use spies, but couldn't figure out how because my ajax won't return anything. </p>
  
  <pre>
  <code>
      submit : function() {
          var url = window.arguments[0];
          var request = new XMLHttpRequest();
          request.open("POST", 'http://'+this.host+'/doSomething', true);
          request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          request.send("param="+param+"&emotions="+this.getParams());
          request.onreadystatechange = function() {
              if(this.readyState == 4) {
                  // alert(this.responseText);
              }
          };
  
      }
  </code>
  </pre>