Bug 963925 - Add test for Highlight All mode. r=Unfocused, a=lsblakk
authorMike de Boer <mdeboer@mozilla.com>
Mon, 17 Feb 2014 15:43:04 +0100
changeset 234605 860e76ec9fe57cc83757089e5946a24fc6456bc3
parent 234604 a910892387e1defe4e2385e89814b6c23ffc71b1
child 234606 d3a94932b8007b98033152e198a0b4fbc334df2d
push id208
push userryanvm@gmail.com
push dateMon, 23 Feb 2015 15:44:39 +0000
treeherdermozilla-b2g37_v2_2@09dafeb43234 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, lsblakk
bugs963925
milestone28.0
Bug 963925 - Add test for Highlight All mode. r=Unfocused, a=lsblakk
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);