MCPcopy
hub / github.com/ampproject/amphtml / installExtensionsInEmbed

Method installExtensionsInEmbed

src/friendly-iframe-embed.js:717–808  ·  view source on GitHub ↗

* Install extensions in the child window (friendly iframe). The pre-install * callback, if specified, is executed after polyfills have been configured * but before the first extension is installed. * @param {!FriendlyIframeEmbed} embed * @param {!./service/extensions-impl.Extensions} ext

(
    embed,
    extensionsService,
    ampdoc,
    extensions,
    preinstallCallback,
    opt_installComplete
  )

Source from the content-addressed store, hash-verified

715 * @return {!Promise}
716 */
717 static installExtensionsInEmbed(
718 embed,
719 extensionsService,
720 ampdoc,
721 extensions,
722 preinstallCallback,
723 opt_installComplete
724 ) {
725 const childWin = ampdoc.win;
726 const parentWin = getWin(childWin.frameElement);
727 setParentWindow(childWin, parentWin);
728 const getDelayPromise = getDelayPromiseProducer();
729
730 return getDelayPromise(undefined)
731 .then(() => {
732 // Install necessary polyfills.
733 installPolyfillsInChildWindow(parentWin, childWin);
734 })
735 .then(getDelayPromise)
736 .then(() => {
737 if (mode.isEsm()) {
738 // TODO: This is combined (ampdoc + shared), not just shared
739 // const css = parentWin.document.querySelector('style[amp-runtime]')
740 // .textContent;
741 installStylesForDoc(
742 ampdoc,
743 ampSharedCss,
744 /* callback */ null,
745 /* opt_isRuntimeCss */ true,
746 /* opt_ext */ 'amp-runtime'
747 );
748 } else {
749 // Install runtime styles.
750 installStylesForDoc(
751 ampdoc,
752 ampSharedCss,
753 /* callback */ null,
754 /* opt_isRuntimeCss */ true,
755 /* opt_ext */ 'amp-runtime'
756 );
757 }
758 })
759 .then(getDelayPromise)
760 .then(() => {
761 if (!childWin.frameElement) {
762 return;
763 }
764 // Run pre-install callback.
765 if (preinstallCallback) {
766 preinstallCallback(ampdoc.win, ampdoc);
767 }
768 })
769 .then(getDelayPromise)
770 .then(() => {
771 if (!childWin.frameElement) {
772 return;
773 }
774 // Install embeddable standard services.

Callers 2

Calls 11

getWinFunction · 0.90
setParentWindowFunction · 0.90
installStylesForDocFunction · 0.90
getDelayPromiseProducerFunction · 0.85
preinstallEmbedMethod · 0.80
startRender_Method · 0.80
setExtensionsKnownMethod · 0.80
thenMethod · 0.45

Tested by

no test coverage detected