test: init script runs onces in iframes (#27057)

Failing test for #26992.
This commit is contained in:
Yury Semikhatsky 2023-09-13 09:46:59 -07:00 committed by GitHub
parent ce43ea7d99
commit 1424185c23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,3 +83,19 @@ it('should work after a cross origin navigation', async ({ page, server }) => {
await page.goto(server.PREFIX + '/tamperable.html');
expect(await page.evaluate(() => window['result'])).toBe(123);
});
it('init script should run only once in iframe', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/26992' });
it.fixme(browserName === 'webkit');
const messages = [];
page.on('console', event => {
if (event.text().startsWith('init script:'))
messages.push(event.text());
});
await page.addInitScript(() => console.log('init script:', location.pathname || 'no url yet'));
await page.goto(server.PREFIX + '/frames/one-frame.html');
expect(messages).toEqual([
'init script: /frames/one-frame.html',
'init script: ' + (browserName === 'firefox' ? 'no url yet' : '/frames/frame.html'),
]);
});