Skip to content

Commit

Permalink
✅Integration tests for amp-video-iframe (ampproject#19196)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco authored and Enriqe committed Nov 28, 2018
1 parent d8c9965 commit b72dc49
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
19 changes: 12 additions & 7 deletions extensions/amp-video-iframe/0.1/amp-video-iframe.js
Expand Up @@ -122,13 +122,18 @@ class AmpVideoIframe extends AMP.BaseElement {
buildCallback() {
const {element} = this;

this.user().assert(!isAdLike(element),
'<amp-video-iframe> does not allow ad iframes. ',
'Please use amp-ad instead.');

this.user().assert(!looksLikeTrackingIframe(element),
'<amp-video-iframe> does not allow tracking iframes. ',
'Please use amp-analytics instead.');
// TODO(alanorozco): On integration tests, `getLayoutBox` will returned
// a cached default value, which makes these assertions fail. Move to
// `describes.integration` to see if that fixes it.
if (!element.hasAttribute('i-amphtml-integration-test')) {
this.user().assert(!isAdLike(element),
'<amp-video-iframe> does not allow ad iframes. ' +
'Please use amp-ad instead.');

this.user().assert(!looksLikeTrackingIframe(element),
'<amp-video-iframe> does not allow tracking iframes. ' +
'Please use amp-analytics instead.');
}

installVideoManagerForDoc(element);
}
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/video-players.html
Expand Up @@ -16,6 +16,7 @@
<script async custom-element="amp-brid-player" src="/dist/v0/amp-brid-player-0.1.max.js"></script>
<script async custom-element="amp-delight-player" src="/dist/v0/amp-delight-player-0.1.max.js"></script>
<script async custom-element="amp-brightcove" src="/dist/v0/amp-brightcove-0.1.max.js"></script>
<script async custom-element="amp-video-iframe" src="/dist/v0/amp-video-iframe-0.1.max.js"></script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="/dist/amp.js"></script>
</head>
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-video-players-helper.js
Expand Up @@ -544,6 +544,7 @@ export function runVideoPlayerIntegrationTests(
video.setAttribute('layout', 'fixed');
video.setAttribute('width', '300px');
video.setAttribute('height', '50vh');
video.setAttribute('i-amphtml-integration-test', '');

video.style.position = 'absolute';
video.style.top = top;
Expand Down
9 changes: 9 additions & 0 deletions test/integration/test-video-players.js
Expand Up @@ -41,6 +41,15 @@ describe.configure().skipIos().run('amp-video', () => {
});
});

describe.configure().skipIos().run('amp-video-iframe', () => {
runVideoPlayerIntegrationTests(fixture => {
const video = fixture.doc.createElement('amp-video-iframe');
video.setAttribute('src', '/examples/amp-video-iframe/frame.html');
video.setAttribute('poster', 'https://placekitten.com/800/450');
return video;
});
});

//TODO(aghassemi, #9379): unskip
describe.skip('amp-youtube', () => {
runVideoPlayerIntegrationTests(fixture => {
Expand Down

0 comments on commit b72dc49

Please sign in to comment.