title: window.addeventlistener in firefox does not fire event on http status 302
body: <p>I am trying to get an authentication script working. It has been supplied by my company, as it is what they are using in other systems. I am having an odd inconsistent behavior between chrome and firefox v19 (what is standard in our desktop environments currently).</p>
  
  <p>The process is pretty simple: we create an iframe, which is pointed to a SAML service. I have an angularJS SPA that is waiting for that SAML service to respond with a JSON object that will tell my app if the user is authenticated or not. Then we either run our app (using <code>angular.bootstrap(document, ['mySPA']);</code> or do something else if unauthorized.</p>
  
  <p>The code in question is this:</p>
  
  <pre><code>(function createIframe() {
  
      var iframe = document.createElement("iframe");
      setAttributes(iframe, {
          "name": "auth",
          "id": "myFrame",
          "src": "https://api.SAML2AuthService",
          "height": "0",
          "width": "0",
          "border": "0"
      });
      document.body.appendChild(iframe);
      // Create IE + others compatible event handler
      authEventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
      authEvent = window[authEventMethod];
      authMessageEvent = authEventMethod == "attachEvent" ? "onmessage" : "message";
  })();
  
  // Listen to auth iframe message
  authEvent(authMessageEvent, function (e) {
      var authorized = false;
      for (var i = 0; i &lt; 2; i++) {
          Authentication = Auth.getInstance();
          if (e.data !== null) {
              data = e.data;
              if (data.isAuthorized === "true" &amp;&amp; data.authorizationToken !== null) {
  
                  Authentication.isAuthorized = e.data.isAuthorized;
                  Authentication.principal = e.data.principal;
                  Authentication.description = e.data.description;
                  Authentication.authorizationToken = e.data.authorizationToken;
                  authorized = true;
                  break;
              }
          }
      }
      if (!authorized) {
          console.log("Unauthorized");
      }
  }, false);
  </code></pre>
  
  <p>Then, we call:</p>
  
  <pre><code>    angular.element(document).ready(function() {
        angular.module( 'mySPA', []
           ...
        });
        angular.bootstrap(document, ['associateDesktop']);
      });
  </code></pre>
  
  <p>However, for reasons beyond my control, the SAML service performs a redirect to get the actual credentials. My browser's debug console shows these as HTTP Status 302, then (I assume) redirected and returned to me as HTTP Status 200.</p>
  
  <p>Specifically, my question is that the <code>AuthEvent</code> event that I attach to window is not always getting fired off. In chrome, if I clear all browsing data (cookies, etc) the <code>authEvent</code> fires, and I get authenticated (or not) as I would expect. In Firefox, if I clear all cached data, the <code>authEvent</code> never gets fired. Am I attaching the event wrong? Does Firefox not call an event like this for a 302? Does angular's <code>ready()</code> function do something I'm not expecting (being impatient)?</p>
  
  <p>Thanks in advance!</p>