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: merge frame url and frame url fragment for getting full url #6398

Merged
merged 3 commits into from Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/FrameManager.ts
Expand Up @@ -1231,7 +1231,7 @@ export class Frame {
*/
_navigated(framePayload: Protocol.Page.Frame): void {
this._name = framePayload.name;
this._url = framePayload.url;
this._url = `${framePayload.url}${framePayload.urlFragment || ''}`;
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/assets/frames/one-frame-url-fragment.html
@@ -0,0 +1 @@
<iframe src='./frame.html&test=fragment'></iframe>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be ./frame.html?test=fragment or ./frame.html#fragment instead?
According to https://github.com/puppeteer/puppeteer/blob/main/new-docs/puppeteer.protocol.page.frame.urlfragment.md the fragment is #fragment and ?param=value is often referred to as query.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@campersau That's a good point. Happy to accept a PR that changes these names!

10 changes: 10 additions & 0 deletions test/frame.spec.ts
Expand Up @@ -256,5 +256,15 @@ describe('Frame specs', function () {
expect(frame1).not.toBe(frame2);
}
);
it('should support url fragment', async () => {
const { page, server } = getTestState();

await page.goto(server.PREFIX + '/frames/one-frame-url-fragment.html');

expect(page.frames().length).toBe(2);
expect(page.frames()[1].url()).toBe(
server.PREFIX + '/frames/frame.html&test=fragment'
);
});
});
});