Fixes - Salesforce compatibility for long-polling transport.
Setting the `context` property on the XHR object is now wrapped in
a try/catch to avoid exceptions if the XHR has been made unextensible.
return new window.XMLHttpRequest();
};
- _self.xhrSend = function(packet) {
- var xhr = _self.newXMLHttpRequest();
+ function _copyContext(xhr) {
+ try {
// Copy external context, to be used in other environments.
xhr.context = _self.context;
+ } catch (e) {
+ // May happen if XHR is wrapped by Object.seal(),
+ // Object.freeze(), or Object.preventExtensions().
+ this._debug('Could not copy transport context into XHR', e);
+ }
+ }
+
+ _self.xhrSend = function(packet) {
+ var xhr = _self.newXMLHttpRequest();
+ _copyContext(xhr);
xhr.withCredentials = true;
xhr.open('POST', packet.url, packet.sync !== true);
var headers = packet.headers;
