<div dir="ltr"><div><div><div>I&#39;m working on controlled environment for analysing malicious JS code. I use PhantomJS (based on Webkit) to execute it.<br><br></div>Now
 I&#39;m trying to intercept get acces to window.location to return fake 
location to analysed script, but I can&#39;t do it. My test JS code:<br>Object.defineProperty(window.location, &quot;href&quot;,<br>{<br>  get: function ()<br>  {<br>    document.write(&quot;HOOK&quot;);<br>  }<br>});<br>console.log(window.location);<br><br></div>When
 I try to execute it I got &quot;Attempting to change access mechanism for an
 unconfigurable property.&quot;. I patched Location.idl: added &quot;Deletable&quot; to
 &quot;attribute DOMString href&quot;, rebuilt the project and test it again. This
 won&#39;t work too. I tried to patch DOMWindow.idl (Deletable on attribute 
location) and other files and now I gave up with it.<br><br></div>Could you please help me with this task? How can I make attributes &quot;hookable&quot; in Webkit?</div>