extensions/amp-analytics/0.1/transport.js
/**
 * Sends a ping request using an iframe, that is removed 5 seconds after
 * it is loaded.
 * This is not available as a standard transport, but rather used for
 * specific, whitelisted requests.
 * Note that this is unrelated to the cross-domain iframe use case above in
 * sendRequestUsingCrossDomainIframe()
 * @param {!Window} win
 * @param {string} request The request URL.
 */
Sends a ping request using an iframe, that is removed 5 seconds after
it is loaded.
This is not available as a standard transport, but rather used for
specific, whitelisted requests.
Note that this is unrelated to the cross-domain iframe use case above in
sendRequestUsingCrossDomainIframe()
@param {!Window} win
@param {string} request The request URL.
Sends a ping request using an iframe that is removed 5 seconds after it is loaded . This is not available as a standard transport but rather used for specific whitelisted requests . Note that this is unrelated to the cross - domain iframe use case above in sendRequestUsingCrossDomainIframe () @param { !Window } win @param { string } request The request URL .
function sendRequestUsingIframe(win, request) {
  assertHttpsUrl(request, 'amp-analytics request');
  const iframe = win.document.createElement('iframe');
  setStyle(iframe, 'display', 'none');
  iframe.onload = iframe.onerror = () => {
    Services.timerFor(win).delay(() => {
      removeElement(iframe);
    }, 5000);
  };
  user().assert(
      parseUrl(request).origin != parseUrl(win.location.href).origin,
      'Origin of iframe request must not be equal to the document origin.' +
      ' See https://github.com/ampproject/' +
      ' amphtml/blob/master/spec/amp-iframe-origin-policy.md for details.');
  iframe.setAttribute('amp-analytics', '');
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
  iframe.src = request;
  win.document.body.appendChild(iframe);
  return iframe;
}
function sendRequestUsingIframe ( win , request ) { assertHttpsUrl ( request , 'amp-analytics request' ) ; const iframe = win . document . createElement ( 'iframe' ) ; setStyle ( iframe , 'display' , 'none' ) ; iframe . onload = iframe . onerror = ( ) => { Services . timerFor ( win ) . delay ( ( ) => { removeElement ( iframe ) ; } , 5000 ) ; } ; user ( ) . assert ( parseUrl ( request ) . origin != parseUrl ( win . location . href ) . origin , 'Origin of iframe request must not be equal to the document origin.' + ' See https://github.com/ampproject/' + ' amphtml/blob/master/spec/amp-iframe-origin-policy.md for details.' ) ; iframe . setAttribute ( 'amp-analytics' , '' ) ; iframe . setAttribute ( 'sandbox' , 'allow-scripts allow-same-origin' ) ; iframe . src = request ; win . document . body . appendChild ( iframe ) ; return iframe ; }
Sends a ping request using an iframe, that is removed 5 seconds after
 it is loaded.
Sends a ping request using an iframe that is removed 5 seconds after it is loaded .
/** @const {!Element} */