src/3p-frame.js
/**
 * Applies a sandbox to the iframe, if the required flags can be allowed.
 * @param {!Element} iframe
 * @visibleForTesting
 */
Applies a sandbox to the iframe, if the required flags can be allowed.
@param {!Element} iframe
@visibleForTesting
Applies a sandbox to the iframe if the required flags can be allowed . @param { !Element } iframe @visibleForTesting
function applySandbox(iframe) {
  if (!iframe.sandbox || !iframe.sandbox.supports) {
    return; 
  }
  const requiredFlags = [
    'allow-top-navigation-by-user-activation',
    'allow-popups-to-escape-sandbox',
  ];
  const otherFlags = [
    'allow-forms',
    'allow-modals',
    'allow-pointer-lock',
    'allow-popups',
    'allow-same-origin',
    'allow-scripts',
  ];
  for (let i = 0; i < requiredFlags.length; i++) {
    const flag = requiredFlags[i];
    if (!iframe.sandbox.supports(flag)) {
      dev().info(TAG, "Iframe doesn't support %s", flag);
      return;
    }
  }
  iframe.sandbox = requiredFlags.join(' ') + ' ' + otherFlags.join(' ');
}
function applySandbox ( iframe ) { if ( ! iframe . sandbox || ! iframe . sandbox . supports ) { return ; } const requiredFlags = [ 'allow-top-navigation-by-user-activation' , 'allow-popups-to-escape-sandbox' , ] ; const otherFlags = [ 'allow-forms' , 'allow-modals' , 'allow-pointer-lock' , 'allow-popups' , 'allow-same-origin' , 'allow-scripts' , ] ; for ( let i = 0 ; i < requiredFlags . length ; i ++ ) { const flag = requiredFlags [ i ] ; if ( ! iframe . sandbox . supports ( flag ) ) { dev ( ) . info ( TAG , "Iframe doesn't support %s" , flag ) ; return ; } } iframe . sandbox = requiredFlags . join ( ' ' ) + ' ' + otherFlags . join ( ' ' ) ; }
Applies a sandbox to the iframe, if the required flags can be allowed.
Applies a sandbox to the iframe if the required flags can be allowed .
// Can't feature detect support // If these flags are not supported by the UA we don't apply any // sandbox. // This only allows navigation when user interacts and thus prevents // ads from auto navigating the user. // Crucial because otherwise even target=_blank opened links are // still sandboxed which they may not expect. // These flags are not feature detected. Put stuff here where either // they have always been supported or support is not crucial. // We should consider turning this off! But since the top navigation // issue is the big one, we'll leave this allowed for now. // Give access to raw mouse movements. // This remains subject to popup blocking, it just makes it supported // at all. // This applies inside the iframe and is crucial to not break the web. // Not allowed // - allow-top-navigation // - allow-orientation-lock // - allow-pointer-lock // - allow-presentation