Skip to content

Commit 5c7cc1a

Browse files
kblokMeir017
authored andcommitted
Handle negative area results in computeQuadArea (#756)
1 parent 8d41b4f commit 5c7cc1a

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Rotated button test</title>
5+
</head>
6+
<body>
7+
<script src="mouse-helper.js"></script>
8+
<button onclick="clicked();">Click target</button>
9+
<style>
10+
button {
11+
transform: rotateY(180deg);
12+
}
13+
</style>
14+
<script>
15+
window.result = 'Was not clicked';
16+
function clicked() {
17+
result = 'Clicked';
18+
}
19+
</script>
20+
</body>
21+
</html>

lib/PuppeteerSharp.Tests/InputTests/InputTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ await Page.EvaluateExpressionAsync(@"{
395395
Assert.Equal("Clicked", await Page.EvaluateExpressionAsync<string>("result"));
396396
}
397397

398+
[Fact]
399+
public async Task ShouldClickARotatedButton()
400+
{
401+
await Page.GoToAsync(TestConstants.ServerUrl + "/input/rotatedButton.html");
402+
await Page.ClickAsync("button");
403+
Assert.Equal("Clicked", await Page.EvaluateExpressionAsync<string>("result"));
404+
}
405+
398406
[Fact]
399407
public async Task ShouldSelectTheTextWithMouse()
400408
{

lib/PuppeteerSharp/ElementHandle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ private decimal ComputeQuadArea(BoxModelPoint[] quad)
518518
var p2 = quad[(i + 1) % quad.Length];
519519
area += ((p1.X * p2.Y) - (p2.X * p1.Y)) / 2;
520520
}
521-
return area;
521+
return Math.Abs(area);
522522
}
523523
}
524524
}

0 commit comments

Comments
 (0)