Skip to content

Commit

Permalink
feat(iframe): adds credentialless attribute for COEP (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinribeiro authored Nov 15, 2024
1 parent 316b2b9 commit 9cb1af2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lite-youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export class LiteYTEmbed extends HTMLElement {
}

const iframeHTML = `
<iframe frameborder="0" title="${this.videoTitle}"
<iframe credentialless frameborder="0" title="${this.videoTitle}"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen
src="https://www.youtube${wantsNoCookie}.com/embed/${embedTarget}autoplay=${autoplay}&${this.params}"
></iframe>`;
Expand Down
12 changes: 6 additions & 6 deletions test/lite-youtube.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('<lite-youtube>', () => {
expect(el.shadowRoot.querySelector('iframe')).to.be.null;
el.click();
expect(el.shadowRoot.querySelector('iframe')).dom.to.equal(
'<iframe frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
'<iframe credentialless frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
);
});

Expand All @@ -85,13 +85,13 @@ describe('<lite-youtube>', () => {
expect(el.shadowRoot.querySelector('iframe')).to.be.null;
el.click();
expect(el.shadowRoot.querySelector('iframe')).dom.to.equal(
'<iframe frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
'<iframe credentialless frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
);
el.videoId = 'VZ9VSypxhEQ';
expect(el.shadowRoot.querySelector('iframe')).to.be.null;
el.click();
expect(el.shadowRoot.querySelector('iframe')).dom.to.equal(
'<iframe frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/VZ9VSypxhEQ?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
'<iframe credentialless frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/VZ9VSypxhEQ?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
);
});

Expand All @@ -100,13 +100,13 @@ describe('<lite-youtube>', () => {
expect(el.shadowRoot.querySelector('iframe')).to.be.null;
el.click();
expect(el.shadowRoot.querySelector('iframe')).dom.to.equal(
'<iframe frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
'<iframe credentialless frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
);
el.playlistId = 'PL-G5r6j4GptH5JTveoLTVqpp7w2oc27Q9';
expect(el.shadowRoot.querySelector('iframe')).to.be.null;
el.click();
expect(el.shadowRoot.querySelector('iframe')).dom.to.equal(
'<iframe frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/?listType=playlist&amp;list=PL-G5r6j4GptH5JTveoLTVqpp7w2oc27Q9&amp;autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
'<iframe credentialless frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube.com/embed/?listType=playlist&amp;list=PL-G5r6j4GptH5JTveoLTVqpp7w2oc27Q9&amp;autoplay=1&amp;start=0&amp;null" title="Test Me"></iframe>',
);
});

Expand Down Expand Up @@ -134,7 +134,7 @@ describe('<lite-youtube>', () => {
);
el.click();
expect(el.shadowRoot.querySelector('iframe')).dom.to.equal(
'<iframe frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube-nocookie.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Video"></iframe>',
'<iframe credentialless frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" src="https://www.youtube-nocookie.com/embed/guJLfqTFfIw?autoplay=1&amp;start=0&amp;null" title="Video"></iframe>',
);
});

Expand Down

0 comments on commit 9cb1af2

Please sign in to comment.