Bug 1372205 - Fix AutocompleteResults.visible_results() to only return visible items. draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 12 Jun 2017 17:54:17 +0200
changeset 594264 e0a046b7bb13a1c959ed6ad38e0629af6cf33471
parent 592668 2a63a6c35033b5cbc6c98cabc7657c7290284691
child 633369 f6110229ea5aaf34d6537651c3c4f931db1045af
push id63970
push userbmo:hskupin@gmail.com
push dateWed, 14 Jun 2017 19:42:48 +0000
bugs1372205
milestone56.0a1
Bug 1372205 - Fix AutocompleteResults.visible_results() to only return visible items. Instead of 'itemCount' the 'maxResults' property of the autocomplete popup has to be used, because it doens't get increased similar to 'itemCount' but stays the same all the time. Further we cannot do an equal check in the puppeteer unit test but only do a check for 0 < visible results <= maxResults, to ensure that items are visible. Using the dot instead, should also give us more and more accurate results across different locales. MozReview-Commit-ID: KZEhq87kvx7
testing/firefox-ui/tests/puppeteer/test_toolbars.py
--- a/testing/firefox-ui/tests/puppeteer/test_toolbars.py
+++ b/testing/firefox-ui/tests/puppeteer/test_toolbars.py
@@ -148,26 +148,23 @@ class TestAutoCompleteResults(PuppeteerM
         except NoSuchElementException:
             # TODO: A NoSuchElementException is thrown here when tests accessing the
             # autocomplete_results element are skipped.
             pass
         finally:
             super(TestAutoCompleteResults, self).tearDown()
 
     def test_popup_elements(self):
-        # TODO: This test is not very robust because it relies on the history
-        # in the default profile.
         self.assertFalse(self.autocomplete_results.is_open)
-        self.browser.navbar.locationbar.urlbar.send_keys('a')
-        results = self.autocomplete_results.results
+        self.browser.navbar.locationbar.urlbar.send_keys('.')
         Wait(self.marionette).until(lambda _: self.autocomplete_results.is_complete)
-        visible_result_count = len(self.autocomplete_results.visible_results)
-        self.assertTrue(visible_result_count > 0)
-        self.assertEqual(visible_result_count,
-                         int(results.get_property('itemCount')))
+        count_visible_results = len(self.autocomplete_results.visible_results)
+        self.assertTrue(count_visible_results > 0)
+        self.assertLessEqual(count_visible_results,
+                             self.autocomplete_results.element.get_property('maxResults'))
 
     def test_close(self):
         self.browser.navbar.locationbar.urlbar.send_keys('a')
         Wait(self.marionette).until(lambda _: self.autocomplete_results.is_open)
         # The Wait in the library implementation will fail this if this doesn't
         # end up closing.
         self.autocomplete_results.close()