Bug 1510162 - Fix intermittent browser/components/aboutconfig/test/browser/browser_search.js. r=bgrins
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Thu, 29 Nov 2018 15:24:15 +0000
changeset 505941 05dbd9368700
parent 505940 8dcdfbc80345
child 505942 0bbffdf069f1
push id10301
push userarchaeopteryx@coole-files.de
push dateThu, 06 Dec 2018 16:36:14 +0000
treeherdermozilla-beta@7d2f3c71997c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1510162
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1510162 - Fix intermittent browser/components/aboutconfig/test/browser/browser_search.js. r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D12888
browser/components/aboutconfig/test/browser/browser_search.js
--- a/browser/components/aboutconfig/test/browser/browser_search.js
+++ b/browser/components/aboutconfig/test/browser/browser_search.js
@@ -19,45 +19,57 @@ add_task(async function test_search() {
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: PAGE_URL,
   }, async browser => {
     let prefArray = Services.prefs.getChildList("");
 
     // Test page loaded with correct number of prefs.
     await ContentTask.spawn(browser, prefArray, aPrefArray => {
-      Assert.equal(content.document.getElementById("prefs").childElementCount,
-                   aPrefArray.length);
+      // The total number of preferences may change at any time because of
+      // operations running in the background, so we only test approximately.
+      // The change in count would be because of one or two added preferences,
+      // but we tolerate a difference of up to 50 preferences just to be safe.
+      // We want thousands of prefs instead of a few dozen that are filtered.
+      Assert.greater(content.document.getElementById("prefs").childElementCount,
+                     aPrefArray.length - 50);
 
-      // Test page search of "button" returns correct number of preferences.
+      // Filter a subset of preferences. The "browser.download." branch is
+      // chosen because it is very unlikely that its preferences would be
+      // modified by other code during the execution of this test.
       let search = content.document.getElementById("search");
-      search.value = "button   ";
+      search.value = "wser.down   ";
       search.focus();
     });
 
     EventUtils.sendKey("return");
     await ContentTask.spawn(browser, prefArray, aPrefArray => {
       let filteredPrefArray =
-          aPrefArray.filter(pref => pref.includes("button"));
+          aPrefArray.filter(pref => pref.includes("wser.down"));
       // Adding +1 to the list since button does not match an exact
       // preference name then a row is added for the user to add a
       // new button preference if desired
       Assert.equal(content.document.getElementById("prefs").childElementCount,
                    filteredPrefArray.length + 1);
 
       // Test empty search returns all preferences.
       let search = content.document.getElementById("search");
       search.value = "";
       search.focus();
     });
 
     EventUtils.sendKey("return");
     await ContentTask.spawn(browser, prefArray, aPrefArray => {
-      Assert.equal(content.document.getElementById("prefs").childElementCount,
-                   aPrefArray.length);
+      // The total number of preferences may change at any time because of
+      // operations running in the background, so we only test approximately.
+      // The change in count would be because of one or two added preferences,
+      // but we tolerate a difference of up to 50 preferences just to be safe.
+      // We want thousands of prefs instead of a few dozen that are filtered.
+      Assert.greater(content.document.getElementById("prefs").childElementCount,
+                     aPrefArray.length - 50);
 
       // Test invalid search returns no preferences.
       let search = content.document.getElementById("search");
       search.value = "aJunkValueasdf";
       search.focus();
     });
 
     EventUtils.sendKey("return");