plugin/boomerang/boomerang-1.0.0.js
/**
				 * Setup an {EventListener} for Event @param{ename}. This function will
				 * make sure the timestamp for the resources request is set and calls
				 * loadFinished should the resource have finished.
				 *
				 * See {@link open()} for it's usage
				 *
				 * @param ename {String} Eventname to listen on via addEventListener
				 * @param stat {String} if that {@link ename} is reached set this
				 * as the status of the resource
				 *
				 * @memberof ProxyXHRImplementation
				 */
Setup an {EventListener} for Event @param{ename}. This function will
make sure the timestamp for the resources request is set and calls
loadFinished should the resource have finished.

See  open() for it's usage

@param ename {String} Eventname to listen on via addEventListener
@param stat {String} if that  ename is reached set this
as the status of the resource


Setup an { EventListener } for Event @param { ename } . This function will make sure the timestamp for the resources request is set and calls loadFinished should the resource have finished . See open () for it ' s usage @param ename { String } Eventname to listen on via addEventListener @param stat { String } if that ename is reached set this as the status of the resource
function addListener(ename, stat) {
					req.addEventListener(
						ename,
						function() {
							if (ename === "readystatechange") {
								resource.timing[readyStateMap[req.readyState]] = BOOMR.now();
								if (req.readyState === 4 && req.status !== 0) {
									if (req.status < 200 || req.status >= 400) {
										resource.status = req.status;
									}
									if (impl.captureXhrRequestResponse) {
										resource.response = {
											text: (req.responseType === "" || req.responseType === "text") ? req.responseText : null,
											xml: (req.responseType === "" || req.responseType === "document") ? req.responseXML : null,
											raw: req.response,
											json: req.responseJSON
										};
										 Work around browser bugs where our Boomerang frame's Object is not equal
										 to the main frame's Object.  This affects "isPlainObj()"-like checks that
										 validate the .constructor is equal to the main frame's Object.
										 e.g.
										 https:github.com/facebook/immutable-js/blob/master/src/utils/isPlainObj.js
										 This seems to mostly affect Safari 11.1.
										if (req.response &&
										    req.response.constructor &&
										    req.response.constructor === BOOMR.boomerang_frame.Object &&
										    BOOMR.boomerang_frame.Object !== w.Object) {
											try {
												 try to switch the constructor to the main window
												req.response.constructor = w.Object;
											}
											catch (e) {
												 NOP
											}
										}
									}
									impl.loadFinished(resource);
								}
								else if (req.readyState === 0 && typeof resource.timing.open === "number") {
									 something called .abort() after the request was started
									resource.status = XHR_STATUS_ABORT;
									impl.loadFinished(resource);
								}
							}
							else {
								 load, timeout, error, abort
								if (ename === "load") {
									if (req.status !== 0 && (req.status < 200 || req.status >= 400)) {
										resource.status = req.status;
									}
								}
								else {
									 this is a timeout/error/abort, so add the status code
									resource.status = (typeof stat === "undefined" ? req.status : stat);
								}
								impl.loadFinished(resource);
							}
						},
						false
					);
				}
function addListener ( ename , stat ) { req . addEventListener ( ename , function ( ) { if ( ename === "readystatechange" ) { resource . timing [ readyStateMap [ req . readyState ] ] = BOOMR . now ( ) ; if ( req . readyState === 4 && req . status !== 0 ) { if ( req . status < 200 || req . status >= 400 ) { resource . status = req . status ; } if ( impl . captureXhrRequestResponse ) { resource . response = { text : ( req . responseType === "" || req . responseType === "text" ) ? req . responseText : null , xml : ( req . responseType === "" || req . responseType === "document" ) ? req . responseXML : null , raw : req . response , json : req . responseJSON } ; if ( req . response && req . response . constructor && req . response . constructor === BOOMR . boomerang_frame . Object && BOOMR . boomerang_frame . Object !== w . Object ) { try { req . response . constructor = w . Object ; } catch ( e ) { } } } impl . loadFinished ( resource ) ; } else if ( req . readyState === 0 && typeof resource . timing . open === "number" ) { resource . status = XHR_STATUS_ABORT ; impl . loadFinished ( resource ) ; } } else { if ( ename === "load" ) { if ( req . status !== 0 && ( req . status < 200 || req . status >= 400 ) ) { resource . status = req . status ; } } else { resource . status = ( typeof stat === "undefined" ? req . status : stat ) ; } impl . loadFinished ( resource ) ; } } , false ) ; }
Setup an {EventListener} for Event @param{ename}.
Setup an { EventListener } for Event @param { ename } .
// Listen here as well, as DOM changes might happen on other listeners // of readyState = 4 (complete), and we want to make sure we've // started the addEvent() if so.  Only listen if the status is non-zero, // meaning the request wasn't aborted.  Aborted requests will fire the // next handler. // put the HTTP error code on the resource if it's not a success // // Work around browser bugs where our Boomerang frame's Object is not equal // to the main frame's Object.  This affects "isPlainObj()"-like checks that // validate the .constructor is equal to the main frame's Object. // e.g. // https://github.com/facebook/immutable-js/blob/master/src/utils/isPlainObj.js // This seems to mostly affect Safari 11.1. // // try to switch the constructor to the main window // NOP // something called .abort() after the request was started // load, timeout, error, abort // put the HTTP error code on the resource if it's not a success // this is a timeout/error/abort, so add the status code