Bug 1490974 Part 3: Add a test that invisible text and text in option tags doesn't generate a find result. r=mikedeboer
authorBrad Werth <bwerth@mozilla.com>
Tue, 05 Mar 2019 20:19:51 +0000
changeset 520342 81d7a246c2b0d47820c3e186a0c9832685be2f77
parent 520341 330d7fe2bf6b43a7b35759f15b303c3092281a74
child 520343 200e4a37af4741224dfc291a6f87e926089fd1c4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1490974
milestone67.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 1490974 Part 3: Add a test that invisible text and text in option tags doesn't generate a find result. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D10632
toolkit/modules/tests/browser/browser.ini
toolkit/modules/tests/browser/browser_Finder_skip_invisible_and_option.js
--- a/toolkit/modules/tests/browser/browser.ini
+++ b/toolkit/modules/tests/browser/browser.ini
@@ -30,16 +30,17 @@ support-files =
 [browser_Finder.js]
 [browser_Finder_hidden_textarea.js]
 skip-if = verify && debug
 [browser_Finder_offscreen_text.js]
 [browser_Finder_overflowed_onscreen.js]
 [browser_Finder_overflowed_textarea.js]
 skip-if = (verify && debug && (os == 'mac' || os == 'linux'))
 [browser_Finder_pointer_events_none.js]
+[browser_Finder_skip_invisible_and_option.js]
 [browser_Finder_vertical_text.js]
 [browser_FinderHighlighter.js]
 skip-if = debug || os = "linux"
 [browser_FinderHighlighter2.js]
 skip-if = debug || os = "linux"
 [browser_Geometry.js]
 [browser_InlineSpellChecker.js]
 [browser_WebNavigation.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/modules/tests/browser/browser_Finder_skip_invisible_and_option.js
@@ -0,0 +1,41 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+add_task(async function test_vertical_text() {
+  const URI = '<body>a<div style="visibility:hidden;">a</div><select><option>a</option></select><select size=2><option>a</option><option>a</option></select></body>';
+  await BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html;charset=utf-8," + encodeURIComponent(URI) },
+    async function(browser) {
+      let finder = browser.finder;
+      let listener = {
+        onFindResult() {
+          ok(false, "callback wasn't replaced");
+        },
+      };
+      finder.addResultListener(listener);
+
+      function waitForFind() {
+        return new Promise(resolve => {
+          listener.onFindResult = resolve;
+        });
+      }
+
+      // Find the target text. There should be three results.
+      let target = "a";
+      let promiseFind = waitForFind();
+      finder.fastFind(target, false, false);
+      let findResult = await promiseFind;
+
+      // Check the results and repeat three times. After the final repeat, make sure we've wrapped to the beginning.
+      let i = 0;
+      for (; i < 3; i++) {
+        isnot(findResult.result, Ci.nsITypeAheadFind.FIND_NOTFOUND, "Should find target text '" + target + "' instance " + (i + 1) + ".");
+
+        promiseFind = waitForFind();
+        finder.findAgain(false, false, false);
+        findResult = await promiseFind;
+      }
+      is(findResult.result, Ci.nsITypeAheadFind.FIND_WRAPPED, "After " + (i + 1) + " searches, we should wrap to first target text.");
+
+      finder.removeResultListener(listener);
+    });
+});