Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load event with non-url subframe #13340

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/playwright-core/src/server/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ export class Frame extends SdkObject {
// We require a particular lifecycle event to be fired in the whole
// frame subtree, and then consider it done.
for (const event of events) {
if (!child._subtreeLifecycleEvents.has(event))
// Wait for commit in the subframe with non-url src instead of other events
// <iframe src="javascript:false"></iframe> <iframe src="data:text/html"></iframe>
if (!child._subtreeLifecycleEvents.has(child._url === '' ? 'commit' : event))
events.delete(event);
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/assets/data-src-frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe src="data:text/html"></iframe>
1 change: 1 addition & 0 deletions tests/assets/javascript-src-frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe src="javascript:false"></iframe>
28 changes: 28 additions & 0 deletions tests/library/browsercontext-page-event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,31 @@ it('should not hang on ctrl-click during provisional load', async ({ context, pa
]);
expect(popup).toBeTruthy();
});

it('should work with javascript-src-frame', async ({ browser, server }) => {
const context = await browser.newContext();
const page = await context.newPage();

await page.goto(server.PREFIX + '/javascript-src-frame.html', { waitUntil: 'commit' });

await page.waitForLoadState('networkidle');
await page.waitForLoadState('domcontentloaded');
await page.waitForLoadState('load');

expect(page.url()).not.toBe('');
await context.close();
});

it('should work with data-src-frame', async ({ browser, server }) => {
const context = await browser.newContext();
const page = await context.newPage();

await page.goto(server.PREFIX + '/data-src-frame.html', { waitUntil: 'commit' });

await page.waitForLoadState('networkidle');
await page.waitForLoadState('domcontentloaded');
await page.waitForLoadState('load');

expect(page.url()).not.toBe('');
await context.close();
});