Bug 963925 - Add test for Highlight All mode. r=Unfocused, a=sledru
authorMike de Boer <mdeboer@mozilla.com>
Mon, 17 Feb 2014 15:43:04 +0100
changeset 182927 90e4b605fdb7e5c253035916265df863a3b58e6d
parent 182926 694327d3251ed4cd58d7a2da274c6b4b6523359a
child 182928 b2a10b07adba69c4417c2e0dd123abe6450f799f
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, sledru
bugs963925
milestone29.0a2
Bug 963925 - Add test for Highlight All mode. r=Unfocused, a=sledru
toolkit/content/tests/chrome/findbar_window.xul
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -86,16 +86,19 @@
       ok(gFindBar.hidden, "Failed to close findbar after testNormalFind");
       testNormalFindWithComposition();
       gFindBar.close();
       ok(gFindBar.hidden, "findbar should be hidden after testNormalFindWithComposition");
       testAutoCaseSensitivityUI();
       testQuickFindText();
       gFindBar.close();
       ok(gFindBar.hidden, "Failed to close findbar after testQuickFindText");
+      testFindWithHighlight();
+      gFindBar.close();
+      ok(gFindBar.hidden, "Failed to close findbar after testFindWithHighlight");
       testFindbarSelection();
       testDrop();
       testQuickFindLink();
       testStatusText();
       testQuickFindClose();
     }
 
     function testFindbarSelection() {
@@ -299,16 +302,62 @@
          "testQuickFindLink: find field is not focused");
 
       var searchStr = "Link Test";
       enterStringIntoFindField(searchStr);
       ok(gBrowser.contentWindow.getSelection() == searchStr,
           "testQuickFindLink: failed to find sample link");
     }
 
+    // See bug 963925 for more details on this test.
+    function testFindWithHighlight() {
+      //clearFocus();
+      gFindBar._findField.value = "";
+
+      let findCommand = document.getElementById("cmd_find");
+      findCommand.doCommand();
+
+      let searchStr = "e";
+      enterStringIntoFindField(searchStr);
+
+      let a = gFindBar._findField.value;
+      let b = gFindBar._browser.finder._fastFind.searchString;
+      let c = gFindBar._browser.finder.searchString;
+      ok(a == b && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
+
+      let oldGetInitialSelection = gFindBar._getInitialSelection;
+      let searchStr = "t";
+      gFindBar._getInitialSelection = () => searchStr;
+      findCommand.doCommand();
+      gFindBar._getInitialSelection = oldGetInitialSelection;
+
+      a = gFindBar._findField.value;
+      b = gFindBar._browser.finder._fastFind.searchString;
+      c = gFindBar._browser.finder.searchString;
+      ok(a == searchStr && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
+
+      let highlightButton = gFindBar.getElement("highlight");
+      highlightButton.click();
+      ok(highlightButton.checked, "testFindWithHighlight: Highlight All should be checked.");
+
+      a = gFindBar._findField.value;
+      b = gFindBar._browser.finder._fastFind.searchString;
+      c = gFindBar._browser.finder.searchString;
+      ok(a == searchStr && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
+
+      gFindBar.onFindAgainCommand();
+      a = gFindBar._findField.value;
+      b = gFindBar._browser.finder._fastFind.searchString;
+      c = gFindBar._browser.finder.searchString;
+      ok(a == b && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
+
+      highlightButton.click();
+      ok(!highlightButton.checked, "testFindWithHighlight: Highlight All should be unchecked.");
+    }
+
     function testQuickFindText() {
       clearFocus();
 
       var event = document.createEvent("KeyEvents");
       event.initKeyEvent("keypress", true, true, null, false, false,
                          false, false, 0, "/".charCodeAt(0));
       gBrowser.contentDocument.documentElement.dispatchEvent(event);