# HG changeset patch # User Michael Ratcliffe # Date 1519923801 0 # Node ID 705748b426e10b52b774b1a59f08987d657a7bcb # Parent 82fdf4e7af7bdeaa760e61946672e0266235069d Bug 1442305 - setFilterState() in head.js fails when setting multiple categories r=nchevobbe MozReview-Commit-ID: 9HxZk5gCI2S diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/head.js b/devtools/client/webconsole/new-console-output/test/mochitest/head.js --- a/devtools/client/webconsole/new-console-output/test/mochitest/head.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/head.js @@ -656,41 +656,33 @@ async function getFilterState(hud) { * netxhr: false, * net: false * } */ async function setFilterState(hud, settings) { const filterBar = await setFilterBarVisible(hud, true); for (let category in settings) { - let check = settings[category]; + let setActive = settings[category]; let button = filterBar.querySelector(`.${category}`); if (!button) { ok(false, `setFilterState() called with a category of ${category}, ` + `which doesn't exist.`); } - info(`Setting the ${category} category to ${check ? "checked" : "disabled"}`); + info(`Setting the ${category} category to ${setActive ? "checked" : "disabled"}`); - let checked = button.classList.contains("checked"); - if (check) { - // Enable filter. - if (checked) { - return; - } + let isChecked = button.classList.contains("checked"); + + if (setActive !== isChecked) { button.click(); + await waitFor(() => { - return button.classList.contains("checked"); - }); - } else if (checked) { - // Disable filter. - button.click(); - await waitFor(() => { - return !button.classList.contains("checked"); + return button.classList.contains("checked") === setActive; }); } } } /** * Set the visibility of the filter bar. *