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

window.performance missing in ClientFunction #3546

Closed
pavelloz opened this issue Mar 8, 2019 · 7 comments
Closed

window.performance missing in ClientFunction #3546

pavelloz opened this issue Mar 8, 2019 · 7 comments
Labels
AREA: client FREQUENCY: level 1 STATE: Need improvement A minor issue that can't be treated as a bug. STATE: Stale An outdated issue that will be automatically closed by the Stale bot. SYSTEM: driver TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@pavelloz
Copy link

pavelloz commented Mar 8, 2019

What is your Test Scenario?

I want to get window.performance object with data inside

What is the Current behavior?

Its empty

What is the Expected behavior?

Will be filled with the same data as i have inside the browser when i inspect the test using .debug()
image

What is your web application and your TestCafe test code?

test('timing works', async t => {
  const getLoadTime = ClientFunction(() => performance.timing);
  console.log(await getLoadTime());
});

Your website URL (or attach your complete example):
https://www.example.com

Steps to Reproduce:

Use example code above to see {} as a result instead of whats actually in the browser.

Your Environment details:

  • testcafe version: 1.1.0
  • node.js version: 10.13.0
  • command-line arguments: npx testcafe chrome
  • browser name and version: chrome 72
  • platform and version: mac os 10.13.6
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 8, 2019
@AndreyBelym AndreyBelym added AREA: client SYSTEM: driver STATE: Need improvement A minor issue that can't be treated as a bug. and removed STATE: Need response An issue that requires a response or attention from the team. labels Mar 11, 2019
@AndreyBelym AndreyBelym added this to the Sprint #30 milestone Mar 11, 2019
@AndreyBelym
Copy link
Contributor

I've reproduced the problem. performance.timing stores all its properties in the prototype, not in the object. The replicator package used by TestCafe for serializing objects and transferring them from a browser to the test code doesn't support this case yet. Thus I've created a feature request in the replicator repository: inikulin/replicator#7.

As a workaround, you can use JSON.stringify/JSON.parse:

const getLoadTime = async t => JSON.parse(await t.eval(() => JSON.stringify(window.performance.timing)));

console.log(await getLoadTime(t));

@pavelloz
Copy link
Author

Thank you :)

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 11, 2019
@AndreyBelym AndreyBelym removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 11, 2019
@AndreyBelym AndreyBelym modified the milestones: Sprint #30, Planned Mar 27, 2019
@rakeshkumartripathy
Copy link

rakeshkumartripathy commented Jul 29, 2020

Hi Guys,

I want to get window.performance.memory object with data inside in TestCafe.

This "window.performance.memory" returns memory stats in Browser Console and I am not able to get the same through TestCafe.

@AndreyBelym Can you take a look into this ?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 29, 2020
@alexey-lin
Copy link
Contributor

Hi @rakeshkumartripathy,

window.performance.memory's properties are non-enumerable, so JSON.stringify ignores them. You can adjust Andrey's sample like this:

const getMemory = async t => JSON.parse(await t.eval(() => {
	const { jsHeapSizeLimit, totalJSHeapSize, usedJSHeapSize } = window.performance.memory;
	return JSON.stringify({ jsHeapSizeLimit, totalJSHeapSize, usedJSHeapSize });
}));

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 29, 2020
@rakeshkumartripathy
Copy link

Thank you @alexey-lin

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

@github-actions github-actions bot added the STATE: Stale An outdated issue that will be automatically closed by the Stale bot. label Sep 28, 2022
@github-actions
Copy link

github-actions bot commented Oct 9, 2022

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.

@github-actions github-actions bot closed this as completed Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AREA: client FREQUENCY: level 1 STATE: Need improvement A minor issue that can't be treated as a bug. STATE: Stale An outdated issue that will be automatically closed by the Stale bot. SYSTEM: driver TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

5 participants