Skip to content

Commit

Permalink
jQuery workloads: use :nth-child() in a querySelector call in each it…
Browse files Browse the repository at this point in the history
…eration (WebKit#367)

This PR fixes the issue WebKit#365: jQuery test only ever marks the first todo item as completed

The bug was caused by jQuery replacing the whole todo list whenever each todo item is toggled.

Fixed it by running querySelector with :nth-child in each iteration.

Co-authored-by: Ryosuke Niwa <rniwa@webkit.org>
  • Loading branch information
2 people authored and jrmuizel committed Jul 23, 2024
1 parent 0f40882 commit 537d576
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions resources/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,8 @@ Suites.push({
}
}),
new BenchmarkTestStep("CompletingAllItems", (page) => {
const checkboxes = page.querySelectorAll(".toggle");
for (let i = 0; i < numberOfItemsToAdd; i++)
checkboxes[i].click();
for (let i = 1; i <= numberOfItemsToAdd; i++)
page.querySelector(`li:nth-child(${i}) .toggle`).click();
}),
new BenchmarkTestStep("DeletingAllItems", (page) => {
for (let i = numberOfItemsToAdd - 1; i >= 0; i--)
Expand Down Expand Up @@ -596,9 +595,8 @@ Suites.push({
}
}),
new BenchmarkTestStep("CompletingAllItems", (page) => {
const checkboxes = page.querySelectorAll(".toggle");
for (let i = 0; i < numberOfItemsToAdd; i++)
checkboxes[i].click();
for (let i = 1; i <= numberOfItemsToAdd; i++)
page.querySelector(`li:nth-child(${i}) .toggle`).click();
}),
new BenchmarkTestStep("DeletingAllItems", (page) => {
for (let i = numberOfItemsToAdd - 1; i >= 0; i--)
Expand Down

0 comments on commit 537d576

Please sign in to comment.