I have a page redirecting when this should not be, and I'm trying to figure out who does it. First I tried to capture window.location:
window.location = (function (location) { // location is now hidden inside a closure. We can override it var Location = Object.create(location); // Location is now our proxy. We can use it to catch changes window.__defineGetter__('location', function () { return Location }); window.__defineSetter__('location', function (x) { debugger; location = x; return x; }); // etc etc, considered assignments to location.href, location.search, location.host etc., as well as calls to location.replace and location.assign }(window.location));
This did not work at all in Chrome. For security reasons, you cannot do setters and getters on window.location. OK. The next thing I tried is observing onunload and onbeforeunload:
['unload', 'beforeunload'].forEach(function (evName) { window.addEventListener(evName, function () { debugger;
I knew that the window.location value would remain unchanged until the onunload event occurred, again for security reasons, but I was hoping for some other key; no such luck. Then I tried to set breakpoints at every point that I can find in my own scripts where it is possible to assign window.location. None of them fall in line with the Chrome debugger. Argh. By the way, this redirect does not occur in FF, and I already tried restarting Chrome. I feel like I really tried everything and didn't go anywhere, which, hopefully, means I'm going to act as a developer? You are welcome?
Is there any way in any browser for me, the person managing the debugger, to break the line redirecting the location of the page? I understand that there are security implications for automatic access to this information, but is there really nothing a privileged developer can do this? If not, what is the normal way to deal with this situation? This seems pretty general, and I don't think anyone likes to block for hours or days on a conceptually simple problem. TIA
javascript google-chrome google-chrome-devtools firebug
PC Jones Jun 25 '12 at 18:18 2012-06-25 18:18
source share