title: window.addEventListener("load", not working on page load
body: <p>I am working on a simple firefox extension. I am stuck with an issue in which i need some help.</p>
  
  <p>I want to add a style attribute in form element whenever page is loaded completely, so i am first trying with a simple alert.</p>
  
  <p>So, i wrote some javascript code like,</p>
  
  <pre><code>var secureSession = function () {
      var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
      return {
          init : function () {
              gBrowser.addEventListener("load", function () {
                  var autoRun = prefManager.getBoolPref("extensions.securesession.autorun");
                  if (autoRun) {
                      alert("Hello World");
                  }
              }, false);
          },
     };
  }();
  
  window.addEventListener("load", secureSession.init, false);
  </code></pre>
  
  <p>I set autorun -> ON, in preferences,</p>
  
  <p>Now, the problem is it's not showing alert by default. means on page load.</p>
  
  <p>It only showing me alert whenever i right click and click on inspect element.</p>
  
  <p>Anyone has any idea about this.</p>
  
  <p>Any help will be appreciated.</p>