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

Controlling asset discovery for relative URLs on pages that use the History API #175

Open
Conduitry opened this issue Jan 19, 2023 · 4 comments
Labels
✨ enhancement New feature or request

Comments

@Conduitry
Copy link

Conduitry commented Jan 19, 2023

I'm using Playwright and Percy on an app that uses the HTML5 History API to navigate between pages. It also contains some relative <link href="...">URLs for loading external CSS files. In browsers, these are resolved, once, when the page loads. If I make use of history.pushState() to trigger client-side-only navigations around the app, the browser doesn't try to re-resolve these relative to the new URL. However, if after such a navigation, I try to take a Percy snapshot, during asset discovery, the (original) serialized DOM has its relative CSS URLs resolved against the new URL, because that's what page.url() returns.

I have a hacky workaround for this in my own project right now, but I'm wondering whether this is something that it would be possible for this package to handle in some way. Even being able to pass in url as an option to percySnapshot() would help, but that's impossible right now, because it will get overridden by page.url(). Even better would be to determine (somehow) what URL the asset discovery phase should be resolving its relative URLs against, but I'm not sure that Playwright exposes such an API or how that would work.

@samarsault
Copy link
Contributor

Can you share a reproducible example for this?

@Conduitry
Copy link
Author

Sure, I've just pushed one to https://github.com/Conduitry-Repros/percy-playwright-175

@github-actions
Copy link

This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the 🍞 stale Closed due to inactivity label Feb 14, 2023
@Conduitry
Copy link
Author

Comment to remove stale label.

@itsjwala itsjwala added ✨ enhancement New feature or request and removed 🍞 stale Closed due to inactivity labels Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants