code: function downloadHighDensityImage(oImage, iDensity) {
  
  		return new Promise(function(resolve, reject) {
  
  			var sSrc = oImage.getSrc(),
  				sDensityAwareSrc = oImage._generateSrcByDensity(sSrc, iDensity),
  				oDomElement = document.createElement("IMG"),
  				bDone = false;
  
  			// check src availability using src property of a dummy dom element
  			// to avoid making AJAX request (may be forbidden if conflicts with CORS)
  			oDomElement.setAttribute("src", sDensityAwareSrc);
  			oDomElement.style.position = "absolute";
  			oDomElement.style.left = "-10000px";
  			oDomElement.style.top = "-10000px";
  
  			function onLoad() {
  				cleanup();
  				resolve(true);
  			}
  
  			function onError() {
  				cleanup();
  				resolve(false);
  			}
  
  			function cleanup() {
  				if (oDomElement && oDomElement.parentNode !== null) { // allow this element and its attached listeners be picked up by the GC
  					oDomElement.parentNode.removeChild(oDomElement);
  				}
  				bDone = true;
  			}
  
  			oDomElement.addEventListener("load", onLoad);
  			oDomElement.addEventListener("error", onError);
  			document.body.appendChild(oDomElement);
  
  			// ensure check is completed even if none of the events are called
  			// (e.g. iOS may not fire load for an already loaded and cached image)
  			setTimeout(function() {
  				if (!bDone) {
  					reject(); // densityAwareSrc availability is not confirmed
  				}
  			}, REQUEST_TIMEOUT);
  
  		});
  	}
docs: ms