title: Overwriting Native Methods in Javascript
body: <p>I'm doing some analysis of some Javascript and I want to keep javascript enabled, but disable all alert() boxes and self.location redirects.</p>
  
  <p>Currently I'm using a regex proxy, but that seems like overkill.</p>
  
  <p>I can override some native methods but not others in Firefox i.e.</p>
  
  <pre><code>window.alert = function('') { return null; }
  alert('test!') // works as expected
  </code></pre>
  
  <p>However when I try to similarly overwrite window.location = (which is an alias for the method call window.assign() ) it does not work</p>
  
  <pre><code>window.location.assign = function('') { return null; }
  window.location.assign('#') // redirects :(
  </code></pre>
  
  <p>I've tried setting Window.prototype.location.assign but i get a "Cannot modify properties of a WrappedNative" exception.</p>
  
  <p>Any alternatives to NoScript for fine grained JS control, or is it possible to overwrite certain Native JS methods?</p>