Bug 916534 - Test for find highlight should work in subframes. r=mikdeboer, a=test-only
authorTom Schuster <evilpies@gmail.com>
Tue, 17 Sep 2013 12:54:35 -0400
changeset 160325 59170fb446848fe76b45a6d408c46e3d6d5eb6a3
parent 160324 0129db608054cd541c4bb1ab0e301dc17a26a1d7
child 160326 290e1e44e8b3b34bb206f7c69861780a24df393f
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikdeboer, test-only
bugs916534
milestone26.0a2
Bug 916534 - Test for find highlight should work in subframes. r=mikdeboer, a=test-only
toolkit/modules/tests/browser/Makefile.in
toolkit/modules/tests/browser/browser_Finder.js
--- a/toolkit/modules/tests/browser/Makefile.in
+++ b/toolkit/modules/tests/browser/Makefile.in
@@ -1,13 +1,13 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MOCHITEST_BROWSER_FILES = \
   browser_DeferredTask.js \
   browser_Deprecated.js \
+  browser_Finder.js \
   browser_Geometry.js \
   browser_InlineSpellChecker.js \
   browser_Troubleshoot.js \
-  
   $(NULL)
new file mode 100644
--- /dev/null
+++ b/toolkit/modules/tests/browser/browser_Finder.js
@@ -0,0 +1,46 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const Ci = Components.interfaces;
+
+let tab, browser;
+
+function test () {
+  waitForExplicitFinish();
+
+  tab = gBrowser.addTab("data:text/html,<iframe srcdoc='content'/>");
+  browser = gBrowser.getBrowserForTab(tab);
+  gBrowser.selectedTab = tab;
+
+  browser.addEventListener("load", startTests, true);
+}
+
+function startTests () {
+  browser.removeEventListener("load", startTests, true);
+
+  let finder = browser.finder;
+  let listener = {
+    onFindResult: function () {
+      ok(false, "callback wasn't replaced");
+    }
+  };
+  finder.addResultListener(listener);
+
+  listener.onFindResult = function (result) {
+    ok(result == Ci.nsITypeAheadFind.FIND_FOUND, "should find string");
+
+    listener.onFindResult = function (result) {
+      ok(result == Ci.nsITypeAheadFind.FIND_NOTFOUND, "should not find string");
+
+      cleanup();
+    }
+    finder.highlight(true, "Bla");
+  }
+  finder.highlight(true, "content");
+}
+
+function cleanup() {
+  gBrowser.removeTab(tab);
+  finish();
+}