Bug 1472491: Part 5p - Add ExtFindChild actor. r=mikedeboer f=felipe
authorKris Maglione <maglione.k@gmail.com>
Sun, 29 Jul 2018 21:44:48 -0700
changeset 486587 100500156e86ffbdea5439283c394a3ddf6c4e15
parent 486586 c7b959b74404be51b72134222c8be46e2d8ad5a9
child 486588 4da0eca21e18abbef9cebc5f0744ddc9384f5c26
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1472491
milestone63.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 1472491: Part 5p - Add ExtFindChild actor. r=mikedeboer f=felipe MozReview-Commit-ID: 3zL8iYeYAPx
browser/components/extensions/test/browser/browser_ext_find.js
toolkit/actors/ExtFindChild.jsm
toolkit/actors/moz.build
toolkit/content/browser-content.js
toolkit/modules/ActorManagerParent.jsm
--- a/browser/components/extensions/test/browser/browser_ext_find.js
+++ b/browser/components/extensions/test/browser/browser_ext_find.js
@@ -33,30 +33,30 @@ function waitForMessage(messageManager, 
       messageManager.removeMessageListener(topic, messageListener);
       resolve(message);
     });
   });
 }
 
 add_task(async function testDuplicatePinnedTab() {
   async function background() {
-    function awaitLoad(tabId) {
+    function awaitLoad(tabId, url) {
       return new Promise(resolve => {
         browser.tabs.onUpdated.addListener(function listener(tabId_, changed, tab) {
-          if (tabId == tabId_ && changed.status == "complete") {
+          if (tabId == tabId_ && changed.status == "complete" && tab.url == url) {
             browser.tabs.onUpdated.removeListener(listener);
             resolve();
           }
         });
       });
     }
 
     let url = "http://example.com/browser/browser/components/extensions/test/browser/file_find_frames.html";
     let tab = await browser.tabs.update({url});
-    await awaitLoad(tab.id);
+    await awaitLoad(tab.id, url);
 
     let data = await browser.find.find("banana", {includeRangeData: true});
     let rangeData = data.rangeData;
 
     browser.test.log("Test that `data.count` is the expected value.");
     browser.test.assertEq(6, data.count, "The value returned from `data.count`");
 
     browser.test.log("Test that `rangeData` has the proper number of values.");
new file mode 100644
--- /dev/null
+++ b/toolkit/actors/ExtFindChild.jsm
@@ -0,0 +1,36 @@
+/* vim: set ts=2 sw=2 sts=2 et tw=80: */
+/* 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/. */
+"use strict";
+
+var EXPORTED_SYMBOLS = ["ExtFindChild"];
+
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
+
+ChromeUtils.defineModuleGetter(this, "FindContent",
+                               "resource://gre/modules/FindContent.jsm");
+
+class ExtFindChild extends ActorChild {
+  async receiveMessage(message) {
+    if (!this._findContent) {
+      this._findContent = new FindContent(this.mm.docShell);
+    }
+
+    let data;
+    switch (message.name) {
+      case "ext-Finder:CollectResults":
+        this.finderInited = true;
+        data = await this._findContent.findRanges(message.data);
+        this.mm.sendAsyncMessage("ext-Finder:CollectResultsFinished", data);
+        break;
+      case "ext-Finder:HighlightResults":
+        data = this._findContent.highlightResults(message.data);
+        this.mm.sendAsyncMessage("ext-Finder:HighlightResultsFinished", data);
+        break;
+      case "ext-Finder:clearHighlighting":
+        this._findContent.highlighter.highlight(false);
+        break;
+    }
+  }
+}
--- a/toolkit/actors/moz.build
+++ b/toolkit/actors/moz.build
@@ -6,16 +6,17 @@
 
 with Files('Finder*.jsm'):
     BUG_COMPONENT = ('Toolkit', 'Find Toolbar')
 
 FINAL_TARGET_FILES.actors += [
     'AudioPlaybackChild.jsm',
     'ControllersChild.jsm',
     'DateTimePickerChild.jsm',
+    'ExtFindChild.jsm',
     'FindBarChild.jsm',
     'FinderChild.jsm',
     'PopupBlockingChild.jsm',
     'PrintingChild.jsm',
     'PurgeSessionHistoryChild.jsm',
     'SelectChild.jsm',
     'SelectionSourceChild.jsm',
     'ThumbnailsChild.jsm',
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -12,18 +12,16 @@ ChromeUtils.import("resource://gre/modul
 ChromeUtils.import("resource://gre/modules/ActorManagerChild.jsm");
 
 ActorManagerChild.attach(this);
 
 ChromeUtils.defineModuleGetter(this, "AutoCompletePopup",
   "resource://gre/modules/AutoCompletePopupContent.jsm");
 ChromeUtils.defineModuleGetter(this, "AutoScrollController",
   "resource://gre/modules/AutoScrollController.jsm");
-ChromeUtils.defineModuleGetter(this, "FindContent",
-  "resource://gre/modules/FindContent.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "formFill",
                                    "@mozilla.org/satchel/form-fill-controller;1",
                                    "nsIFormFillController");
 
 var global = this;
 
 var AutoScrollListener = {
@@ -76,43 +74,8 @@ let AutoComplete = {
         this._connected = false;
       }
       break;
     }
   },
 };
 
 AutoComplete.init();
-
-let ExtFind = {
-  init() {
-    addMessageListener("ext-Finder:CollectResults", this);
-    addMessageListener("ext-Finder:HighlightResults", this);
-    addMessageListener("ext-Finder:clearHighlighting", this);
-    this.init = null;
-  },
-
-  _findContent: null,
-
-  async receiveMessage(message) {
-    if (!this._findContent) {
-      this._findContent = new FindContent(docShell);
-    }
-
-    let data;
-    switch (message.name) {
-      case "ext-Finder:CollectResults":
-        this.finderInited = true;
-        data = await this._findContent.findRanges(message.data);
-        sendAsyncMessage("ext-Finder:CollectResultsFinished", data);
-        break;
-      case "ext-Finder:HighlightResults":
-        data = this._findContent.highlightResults(message.data);
-        sendAsyncMessage("ext-Finder:HighlightResultsFinished", data);
-        break;
-      case "ext-Finder:clearHighlighting":
-        this._findContent.highlighter.highlight(false);
-        break;
-    }
-  },
-};
-
-ExtFind.init();
--- a/toolkit/modules/ActorManagerParent.jsm
+++ b/toolkit/modules/ActorManagerParent.jsm
@@ -126,16 +126,27 @@ let ACTORS = {
     child: {
       module: "resource://gre/actors/DateTimePickerChild.jsm",
       events: {
         "MozOpenDateTimePicker": {},
       },
     },
   },
 
+  ExtFind: {
+    child: {
+      module: "resource://gre/actors/ExtFindChild.jsm",
+      messages: [
+        "ext-Finder:CollectResults",
+        "ext-Finder:HighlightResults",
+        "ext-Finder:clearHighlighting",
+      ]
+    },
+  },
+
   FindBar: {
     child: {
       module: "resource://gre/actors/FindBarChild.jsm",
       events: {
         "keypress": {mozSystemGroup: true},
       },
     },
   },