Skip to content

Commit

Permalink
✅ amp-youtube: add amp=1 to the url (ampproject#20821)
Browse files Browse the repository at this point in the history
  • Loading branch information
aghassemi authored Feb 13, 2019
1 parent b58b6fa commit 84f701f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extensions/amp-youtube/0.1/amp-youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -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&amp=1`;
}

/**
Expand Down
15 changes: 12 additions & 3 deletions extensions/amp-youtube/0.1/test/test-amp-youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -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&amp=1&playsinline=1`;
const EXAMPLE_LIVE_CHANNELID_URL = `https://www.youtube.com/embed/live_stream?channel=${EXAMPLE_LIVE_CHANNELID}&enablejsapi=1&amp=1&playsinline=1`;
const EXAMPLE_NO_COOKIE_VIDEOID_URL = `https://www.youtube-nocookie.com/embed/${EXAMPLE_VIDEOID}?enablejsapi=1&amp=1&playsinline=1`;

describes.realWin('amp-youtube', {
amp: {
Expand Down Expand Up @@ -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': '',
Expand Down

0 comments on commit 84f701f

Please sign in to comment.