From 2db06045eca83c23826edb0f52219d02582b32ee Mon Sep 17 00:00:00 2001 From: Ali Ghassemi Date: Tue, 12 Feb 2019 23:21:22 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20amp-youtube:=20add=20amp=3D1=20to?= =?UTF-8?q?=20the=20url=20(#20821)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/amp-youtube/0.1/amp-youtube.js | 2 +- .../amp-youtube/0.1/test/test-amp-youtube.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/extensions/amp-youtube/0.1/amp-youtube.js b/extensions/amp-youtube/0.1/amp-youtube.js index b2f7b9b393a32..9309c7d60c831 100644 --- a/extensions/amp-youtube/0.1/amp-youtube.js +++ b/extensions/amp-youtube/0.1/amp-youtube.js @@ -180,7 +180,7 @@ class AmpYoutube extends AMP.BaseElement { descriptor = 'live_stream?channel=' + `${encodeURIComponent(this.liveChannelid_ || '')}&`; } - return `${baseUrl}${descriptor}enablejsapi=1`; + return `${baseUrl}${descriptor}enablejsapi=1&=1`; } /** diff --git a/extensions/amp-youtube/0.1/test/test-amp-youtube.js b/extensions/amp-youtube/0.1/test/test-amp-youtube.js index 375fe45fecbbe..506362b7fb08c 100644 --- a/extensions/amp-youtube/0.1/test/test-amp-youtube.js +++ b/extensions/amp-youtube/0.1/test/test-amp-youtube.js @@ -21,9 +21,9 @@ import {listenOncePromise} from '../../../../src/event-helper'; const EXAMPLE_VIDEOID = 'mGENRKrdoGY'; const EXAMPLE_LIVE_CHANNELID = 'UCB8Kb4pxYzsDsHxzBfnid4Q'; -const EXAMPLE_VIDEOID_URL = `https://www.youtube.com/embed/${EXAMPLE_VIDEOID}?enablejsapi=1&playsinline=1`; -const EXAMPLE_LIVE_CHANNELID_URL = `https://www.youtube.com/embed/live_stream?channel=${EXAMPLE_LIVE_CHANNELID}&enablejsapi=1&playsinline=1`; -const EXAMPLE_NO_COOKIE_VIDEOID_URL = `https://www.youtube-nocookie.com/embed/${EXAMPLE_VIDEOID}?enablejsapi=1&playsinline=1`; +const EXAMPLE_VIDEOID_URL = `https://www.youtube.com/embed/${EXAMPLE_VIDEOID}?enablejsapi=1&=1&playsinline=1`; +const EXAMPLE_LIVE_CHANNELID_URL = `https://www.youtube.com/embed/live_stream?channel=${EXAMPLE_LIVE_CHANNELID}&enablejsapi=1&=1&playsinline=1`; +const EXAMPLE_NO_COOKIE_VIDEOID_URL = `https://www.youtube-nocookie.com/embed/${EXAMPLE_VIDEOID}?enablejsapi=1&=1&playsinline=1`; describes.realWin('amp-youtube', { amp: { @@ -111,6 +111,15 @@ describes.realWin('amp-youtube', { }); }); + it('should add amp=1 to the iframe src', () => { + return getYt({ + 'data-videoid': datasource, + }).then(yt => { + const iframe = yt.querySelector('iframe'); + expect(iframe.src).to.contain('amp=1'); + }); + }); + it('should change defaults for some data-param-* when autoplaying', () => { return getYt({ 'autoplay': '',