diff --git a/tests/browser/browser.js b/tests/browser/browser.js index d4eb6b28e0..c188e04cc7 100644 --- a/tests/browser/browser.js +++ b/tests/browser/browser.js @@ -474,3 +474,34 @@ describe.skip('next/link client-side navigation', () => { await page.setViewport(initialViewport) }) }) + +describe('iframe pages', () => { + it('can open YouTube embed iframes', async () => { + // Going to create a fresh page instance, so we can intercept the requests. + const newPage = await browser.newPage() + + await newPage.setRequestInterception(true) + const interceptedURLs = [] + newPage.on('request', (request) => { + interceptedURLs.push(request.url()) + request.continue() + }) + const failedURLs = [] + newPage.on('requestfailed', (request) => { + failedURLs.push(request.url()) + request.continue() + }) + + // Hardcoded path to a page where we know we have a YouTube embed + const res = await newPage.goto('http://localhost:4001/en/codespaces') + + expect(res.ok()).toBeTruthy() + expect(failedURLs.length, `Following URLs ${failedURLs.join(', ')} failed`).toBeFalsy() + + const iframeSrc = await newPage.$eval('iframe', (el) => el.src) + expect(iframeSrc.startsWith('https://www.youtube-nocookie.com/embed')).toBeTruthy() + expect( + interceptedURLs.filter((url) => url.startsWith('https://www.youtube-nocookie.com/')).length + ).toBeTruthy() + }) +})