View Full Version : Adding a function to Object.prototype breaks Ajax.request

2 Dec 2009, 12:08 PM
>>> Ext.Ajax.request({url:'/'})
GET http://frontend.local/?_dc=1259784357367
200 OK
23ms ext-base-debug.js (line 2628)
Object conn=XMLHttpRequest tId=0
>>> Object.prototype.doSomething = function() {};
>>> Ext.Ajax.request({url:'/'})
[Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" location: "JS frame :: http://frontend.local/ :: anonymous :: line 78" data: no]
[Break on this error] (78 out of range 45)Why would that be? Adding a non-function object to the prototype doesn't seem to cause this problem.

The above session was produced in Firefox 3.0.14 through the Firebug console and with ExtJS 3.03.

2 Dec 2009, 1:23 PM
In the script in which I first observed this problem, the error is coming from ext-base-debug.js, specifically line 27 of ext-base-ajax.js:

conn.setRequestHeader(prop, headers[prop]);

In my first console example, the error points to this line of Ext.urlDecode:

return url + (url.indexOf('?') === -1 ? '?' : '&') + s;