I am trying to override document.cookie in my Chrome extension and I'm having a lot of trouble getting the original document.cookie functionality to work at the same time. Currently I have this:
var _cookie = document.cookie;
document.__defineSetter__("cookie", function(the_cookie) {_cookie=the_cookie;} );
document.__defineGetter__("cookie", function() {return _cookie;} );
I am injecting the JS from a content script using the technique from here.
The behavior I'm seeing is that my re-defined setter and getter get called, but the original function is no longer working. For example, I can check _cookie and document.cookie using the Developer Tools and see that they have the same, expected value, but no cookies ever appear in Chrome's cookie store.
Can anyone tell me how I am breaking the original document.cookie functionality? Is the problem that document.cookie is a property, so I'm not actually getting a pointer to the original setter?