diff --git a/extensions/amp-story/1.0/amp-story.js b/extensions/amp-story/1.0/amp-story.js index be03be1ed702..1039fc2238c2 100644 --- a/extensions/amp-story/1.0/amp-story.js +++ b/extensions/amp-story/1.0/amp-story.js @@ -1016,6 +1016,7 @@ export class AmpStory extends AMP.BaseElement { .then(() => { this.markStoryAsLoaded_(); this.initializeLiveStory_(); + this.initializeStoryPlayer_(); }); // Story is being prerendered: resolve the layoutCallback when the first @@ -1290,6 +1291,20 @@ export class AmpStory extends AMP.BaseElement { activePage.next(opt_isAutomaticAdvance); } + /** + * Installs amp-viewer-integration script in case story is inside an + * amp-story-player. + */ + initializeStoryPlayer_() { + if (this.viewer_.getParam('storyPlayer') !== 'v0') { + return; + } + Services.extensionsFor(this.getAmpDoc().win).installExtensionForDoc( + this.getAmpDoc(), + 'amp-viewer-integration' + ); + } + /** * Handles EventType.NO_NEXT_PAGE events. * @private diff --git a/src/amp-story-player.js b/src/amp-story-player.js index d2048455d0ac..47e95615bcdf 100644 --- a/src/amp-story-player.js +++ b/src/amp-story-player.js @@ -129,9 +129,6 @@ export class AmpStoryPlayer { this.initializeLoadingListeners_(iframeEl); this.rootEl_.appendChild(iframeEl); - // TODO(#26308): enable messaging when multiple documents are supported. - return; - this.initializeHandshake_(story, iframeEl).then( messaging => { const iframeIdx = findIndex( @@ -206,10 +203,9 @@ export class AmpStoryPlayer { * @private */ layoutIframe_(story, iframe) { - // TODO(#26308): enable messaging when multiple documents are supported. - // const {href} = this.getEncodedLocation_(story.href); + const {href} = this.getEncodedLocation_(story.href); - iframe.setAttribute('src', story.href); + iframe.setAttribute('src', href); } /** @@ -226,6 +222,7 @@ export class AmpStoryPlayer { 'amp_js_v': '0.1', 'visibilityState': 'inactive', 'origin': url.origin, + 'storyPlayer': 'v0', }); const fragmentParam = getFragment(href);