I would like to change the context of the javascript executed in the webkit developer tool/firebug console to execute its code like it is running from inside an iframe on th
In today's Chrome (version 52), all you have to do is select the iframe in the "Elements" tab of the dev tools. Anything you run in the JS console will automatically run in the context of the selected iframe.
For example, here I've selected an iframe, and when I type document.location.pathname
into the console it returns the src attribute of the iframe, instead of the URL from the address bar: