Bug 1064580 - Rewrote browser_bug982298.js and added a definition for onMatchesCountResult to the listeners since RemoteFinder.jsm expects it to be present. Also add an error check in Finder.jsm for empty selections. r=evilpie
authorJared Wein <jwein@mozilla.com>
Fri, 18 Mar 2016 12:26:49 -0400
changeset 289536 dbba8191f3c1e22505f5e5d5b8537f719eafb51d
parent 289535 16654149f9a1c32cf75b15549d2505d3b08c4a26
child 289537 95c8cb6f15151ddcc575efccabf8de28ad6b7673
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1064580, 982298
milestone48.0a1
Bug 1064580 - Rewrote browser_bug982298.js and added a definition for onMatchesCountResult to the listeners since RemoteFinder.jsm expects it to be present. Also add an error check in Finder.jsm for empty selections. r=evilpie MozReview-Commit-ID: 7vi42sp0M5
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_bug1198465.js
toolkit/content/tests/browser/browser_bug982298.js
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -1,21 +1,19 @@
 [DEFAULT]
 support-files =
   head.js
   file_contentTitle.html
   audio.ogg
-
 [browser_autoscroll_disabled.js]
 [browser_browserDrop.js]
 skip-if = buildapp == 'mulet' || e10s # Relies on drop to be handled in the parent process
 [browser_bug295977_autoscroll_overflow.js]
 [browser_bug594509.js]
 [browser_bug982298.js]
-skip-if = e10s # Bug 1064580
 [browser_bug1198465.js]
 [browser_contentTitle.js]
 [browser_default_image_filename.js]
 [browser_f7_caret_browsing.js]
 skip-if = e10s
 [browser_findbar.js]
 [browser_input_file_tooltips.js]
 [browser_isSynthetic.js]
--- a/toolkit/content/tests/browser/browser_bug1198465.js
+++ b/toolkit/content/tests/browser/browser_bug1198465.js
@@ -63,10 +63,10 @@ add_task(function* () {
   // doesn't really matter.
   findBar.onCurrentSelection("foo", true);
   ok(!findBar._startFindDeferred, "prefilled value fetched");
   is(findBar._findField.value, "ab", "ab kept instead of prefill value");
 
   EventUtils.sendChar("c", window);
   is(findBar._findField.value, "abc", "c is appended after ab");
 
-  gBrowser.removeTab(aTab);
+  yield BrowserTestUtils.removeTab(aTab);
 });
--- a/toolkit/content/tests/browser/browser_bug982298.js
+++ b/toolkit/content/tests/browser/browser_bug982298.js
@@ -1,100 +1,70 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-var Ci = Components.interfaces;
-
-var tab;
-var browser;
-
 const scrollHtml =
   "<textarea id=\"textarea1\" row=2>Firefox\n\nFirefox\n\n\n\n\n\n\n\n\n\n" +
   "</textarea><a href=\"about:blank\">blank</a>";
 
-const scrollTest =
-  "var textarea = content.document.getElementById(\"textarea1\");" +
-  "textarea.scrollTop = textarea.scrollHeight;" +
-  "sendAsyncMessage(\"ScrollDone\", { });"
-
-function test()
-{
-  waitForExplicitFinish();
-
-  tab = gBrowser.addTab("data:text/html;base64," +
-                        btoa(scrollHtml));
-  browser = gBrowser.getBrowserForTab(tab);
-  gBrowser.selectedTab = tab;
-
-  browser.addEventListener("load", find, true);
-  info("waiting for load event");
-}
+add_task(function*() {
+  let url = "data:text/html;base64," + btoa(scrollHtml);
+  yield BrowserTestUtils.withNewTab({gBrowser, url}, function*(browser) {
+    let awaitFindResult = new Promise(resolve => {
+      let listener = {
+        onFindResult(aData) {
+          info("got find result");
+          browser.finder.removeResultListener(listener);
 
-function find()
-{
-  info("got load event in 'find' function");
-  browser.removeEventListener("load", find, true);
-  let listener = {
-    onFindResult(aData) {
-      info("got find result");
-      browser.finder.removeResultListener(listener);
-
-      ok(aData.result == Ci.nsITypeAheadFind.FIND_FOUND, "should find string");
-
-      browser.messageManager.addMessageListener("ScrollDone",
-                                                function f(aMsg) {
-        info("got ScrollDone event");
-        browser.messageManager.removeMessageListener("ScrollDone", f);
-        browser.loadURI("about:blank");
-        browser.addEventListener("load", findAgain, true);
-      });
-
-      // scroll textarea to bottom
-      browser.messageManager.loadFrameScript("data:text/javascript;base64," +
-                                             btoa(scrollTest), false);
+          ok(aData.result == Ci.nsITypeAheadFind.FIND_FOUND, "should find string");
+          resolve();
+        },
+        onCurrentSelection() {},
+        onMatchesCountResult() {}
+      };
+      info("about to add results listener, open find bar, and send 'F' string");
+      browser.finder.addResultListener(listener);
+    });
+    gFindBar.onFindCommand();
+    EventUtils.sendString("F");
+    info("added result listener and sent string 'F'");
+    yield awaitFindResult;
 
-    },
-    onCurrentSelection() {}
-  };
-  info("about to add results listener, open find bar, and send 'F' string");
-  browser.finder.addResultListener(listener);
-  gFindBar.onFindCommand();
-  EventUtils.sendString("F");
-  info("added result listener and sent string 'F'");
-}
+    let awaitScrollDone = BrowserTestUtils.waitForMessage(browser.messageManager, "ScrollDone");
+    // scroll textarea to bottom
+    const scrollTest =
+      "var textarea = content.document.getElementById(\"textarea1\");" +
+      "textarea.scrollTop = textarea.scrollHeight;" +
+      "sendAsyncMessage(\"ScrollDone\", { });"
+    browser.messageManager.loadFrameScript("data:text/javascript;base64," +
+                                           btoa(scrollTest), false);
+    yield awaitScrollDone;
+    info("got ScrollDone event");
+    yield BrowserTestUtils.loadURI(browser, "about:blank");
+    yield BrowserTestUtils.browserLoaded(browser);
 
-function findAgain()
-{
-  info("got load event in 'findAgain' function");
-  browser.removeEventListener("load", findAgain, true);
+    ok(browser.currentURI.spec == "about:blank", "got load event for about:blank");
 
-  ok(browser.currentURI.spec == "about:blank", "cannot navigate to about:blank");
-  let listener = {
-    onFindResult(aData) {
-      info("got find result #2");
-      browser.finder.removeResultListener(listener);
-      cleanup();
-    },
-    onCurrentSelection() {}
-  };
+    let awaitFindResult2 = new Promise(resolve => {
+      let listener = {
+        onFindResult(aData) {
+          info("got find result #2");
+          browser.finder.removeResultListener(listener);
+          resolve();
+        },
+        onCurrentSelection() {},
+        onMatchesCountResult() {}
+      };
 
-  browser.finder.addResultListener(listener);
-  // find again needs delay for crash test
-  setTimeout(function() {
-    // ignore exception if occured
-    try {
-      info("about to send find again command");
-      gFindBar.onFindAgainCommand(false);
-      info("sent find again command");
-    } catch (e) {
-      info("got exception from onFindAgainCommand: " + e);
-    }
-    cleanup();
-  }, 0);
-  info("added result listener");
-}
-
-function cleanup()
-{
-  info("in cleanup function");
-  gBrowser.removeTab(tab);
-  finish();
-}
+      browser.finder.addResultListener(listener);
+      info("added result listener");
+    });
+    // find again needs delay for crash test
+    setTimeout(function() {
+      // ignore exception if occured
+      try {
+        info("about to send find again command");
+        gFindBar.onFindAgainCommand(false);
+        info("sent find again command");
+      } catch (e) {
+        info("got exception from onFindAgainCommand: " + e);
+      }
+    }, 0);
+    yield awaitFindResult2;
+  });
+});