title: jasmine mock window object
body: <p>How do I mock window object? I'm doing firefox extension and I want to use jasmine for javascript testing.</p>
  
  <p>In my javascript I have </p>
  
  <pre>
  <code>
  function submit() {
  ...
  var url = window.arguments[0];
  ...
  }
  </code>
  </pre>
  
  <p>Obviously, I have to mock window.arguments[0] in jasmine because that object doesn't exists if not passing any parameter from window.openDialog</p>
  
  <p>This is my attempt to mock it with "with"</p>
  
  <pre>
  <code>
  it("should submit to server", function() {
  
          var localContext = {
              "window": {
                  arguments: ["http://localhost"]
              }
  
          }
  
          with(localContext);
  </code>
  </pre>
  
  <p>But I still get this error TypeError: Cannot read property '0' of undefined, it's like when the test is run window.arguments[0] gets wiped out with the real window, because if I do </p>
  
  <p><code>
  window.arguments[0]
  </code></p>
  
  <p>inside the test, it prints out "http://localhost" correctly. but when it comes to submit() method it shows the error that window.argument is undefined. </p>