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: handle negative area results in computeQuadArea #3413
fix: handle negative area results in computeQuadArea #3413
Conversation
This patch fixes a case in which computeQuadArea calculates the area size correctly, but returns the area as a negative number. This occurs when DOM.getContentQuads returns quads in a specific order. E.g. the array: [ { x: 463, y: 68.5 },{ x: 437, y: 68.5 },{ x: 437, y: 94.5 },{ x: 463, y: 94.5 } ] will receive area size of -676.
This patch fixes a case in which computeQuadArea calculates the area size correctly, but returns the area as a negative number. This occurs when DOM.getContentQuads returns quads in a specific order. E.g. the array: [ { x: 463, y: 68.5 },{ x: 437, y: 68.5 },{ x: 437, y: 94.5 },{ x: 463, y: 94.5 } ] will receive area size of -676.
Thanks for the PR! Do you have a test case that covers this? |
My pleasure :-) There's no problem of creating a test case for this fix. From what I see it has to depend only on the computeQuadArea function in order to be hermetic. Do you write tests in your package that test a single function? |
A test for this would set up some html/css to produce quads in the right order. Then it would call elementHandle.click on the element with the strange quads, and verify that it indeed was clicked. You can find similar tests in input.spec.js |
that's what I thought, I was concerned that an element like that might stop producing strange quads order in future versions of chromium(because of possible change in DOM.getContentQuads), anyway, i'll create a test for this case and add it. |
added a test for the fix in computeQuadArea. A rotated element causes the quads to be returned in a different order and to receive a negative area in previous computeQuadArea.
…/puppeteer into fix-computeQuadArea
Hi, added a test case to the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, thanks!
My pleasure, Thanks! |
This patch fixes a case in which computeQuadArea calculates the area size correctly, but returns the area as a negative number.
This occurs when DOM.getContentQuads returns quads in a specific order.
E.g. the array: [ { x: 463, y: 68.5 },{ x: 437, y: 68.5 },{ x: 437, y: 94.5 },{ x: 463, y: 94.5 } ] received area size of -676.