Is it possible to override document.cookie in WebKit?

In Firefox, you can use the following ...

HTMLDocument.prototype.__defineGetter__("cookie",function (){return "foo=bar";});
HTMLDocument.prototype.__defineSetter__("cookie",function (){});

This does not cause errors in WebKit, and WebKit definitely supports __defineGetter__and __defineSetter__, but it does not work. Guessing WebKit somehow protects this property.

So, any ideas on how to achieve the same effect in WebKit?

+5
source share
1 answer

Have you tried to define the getter / setter pair on the document itself, and not on the prototype?

document.__defineGetter__("cookie", function() {} );
document.__defineSetter__("cookie", function() {} );

I know this does not matter, but I do not underestimate the quirks of the browser. Even with WebKit.

Update

Chrome 2, , , . , , WebKit, Google Chrome JavaScript, WebKit.

+4

All Articles