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

compatibility with Emulation.setVirtualTimePolicy #264

Open
dreyks opened this issue Apr 24, 2024 · 9 comments
Open

compatibility with Emulation.setVirtualTimePolicy #264

dreyks opened this issue Apr 24, 2024 · 9 comments

Comments

@dreyks
Copy link
Contributor

dreyks commented Apr 24, 2024

I'm trying to mock time on the frontend, for this I'm mocking time on the backend using ActiveSupport's travel_to and then trying to make it propagate to the browser

travel_to Time.zone.local(2024, 'jan', 1)
page.driver.browser.page.command(
  'Emulation.setVirtualTimePolicy',
  policy: 'pause',
  initialVirtualTime: Time.zone.now.to_i
)
p page.driver.browser.evaluate('(new Date()).toString()')

this does work returning Mon Jan 01 2024 00:00:00 but then i get an error

Ferrum::PendingConnectionsError: Request to http://127.0.0.1:55665/ reached server, but there are still pending connections: http://127.0.0.1:55665/

looks like something doesn't work well with virtual time

according to the docs policy: 'pause' means that browser is not allowed to fast-forward the time when it's out of work
if i pass policy: 'advance' ferrum doesn't complain but the time advances too quickly: one visit and it's already the next month

any ideas?

@route
Copy link
Member

route commented Apr 26, 2024

Could you attach FERRUM_DEBUG logs as well?

@dreyks
Copy link
Contributor Author

dreyks commented Apr 26, 2024

@route
Copy link
Member

route commented Apr 26, 2024

There's no Page.frameStoppedLoading event signaling that frame is loaded. Could you try same without setVirtualTimePolicy and check if this event appears?

@dreyks
Copy link
Contributor Author

dreyks commented Apr 26, 2024

@route
Copy link
Member

route commented May 6, 2024

Sorry, this convo slipped thru the cracks. I'm afraid it's Chrome's issue then. We should raise an issue like this one https://issues.chromium.org/issues/40923369 though fix is not going to happen quick. Could you please create one?

@dreyks
Copy link
Contributor Author

dreyks commented May 6, 2024

so is the issue in that chrome doesn't send Page.frameStoppedLoading when the timer is emulated?

@route
Copy link
Member

route commented May 6, 2024

@dreyks yes exactly

@dreyks
Copy link
Contributor Author

dreyks commented May 6, 2024

ok, thx, I'll do that. let's keep the issue open, I'll post the link to a ticket when i make one

@route
Copy link
Member

route commented May 7, 2024

I linked wrong issue, the updated comment has a link on a better one with better explanation. Bad thing is that it takes them forever to fix anything, so don't expect any real quick fix :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants