Closed Bug 1009313 Opened 10 years ago Closed 10 years ago

ContentSearch.jsm should call nsIBrowserSearchService.init

Categories

(Firefox :: Search, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
Firefox 32

People

(Reporter: adw, Assigned: adw)

References

Details

(Whiteboard: p=5 s=it-32c-31a-30b.2 [qa-])

Attachments

(1 file)

I forgot to have ContentSearch.jsm call nsIBrowserSearchService.init, so if the service isn't initialized before ContentSearch uses it, you get:

> DEPRECATION WARNING: Search service falling back to synchronous
> initialization. This is generally the consequence of an add-on
> using a deprecated search service API.
Whiteboard: p=0 s=it-32c-31a-30b.2 [qa?]
Flags: firefox-backlog+
Whiteboard: p=0 s=it-32c-31a-30b.2 [qa?] → p=5 s=it-32c-31a-30b.2 [qa?]
Whiteboard: p=5 s=it-32c-31a-30b.2 [qa?] → p=5 s=it-32c-31a-30b.2 [qa-]
Attached patch patchSplinter Review
This adds new _initService calls in the module's two entry points, receiveMessage and observe.  That way everything after the entry points can assume the service has been initialized.
Attachment #8425069 - Flags: review?(felipc)
Attachment #8425069 - Flags: review?(felipc) → review+
Comment on attachment 8425069 [details] [diff] [review]
patch

Some drive-by comments, feel free to ignore...

>diff --git a/browser/modules/ContentSearch.jsm b/browser/modules/ContentSearch.jsm

>-Cu.import("resource://gre/modules/Services.jsm");
>+XPCOMUtils.defineLazyModuleGetter(this, "Services",
>+  "resource://gre/modules/Services.jsm");

>+Cu.import("resource://gre/modules/XPCOMUtils.jsm");

Not a big deal, but this is a bit strange - why lazy import Services.jsm, but not XPCOMUtils? Generally both XPCOMUtils and Services are treated as "guaranteed to already be imported" and thus not lazy loaded.

>   observe: function (subj, topic, data) {

>+    this._initService().then(() => {
>+      switch (topic) {
>+      case "browser-search-engine-modified":

I don't think it's possible for this topic to be fired unless the search service is initialized, so the _initService call here should be redundant? It looks like waiting an extra spin of the event loop shouldn't really matter though.

>+  _initService: function () {

>+      Services.search.init(() => deferred.resolve());

Not sure you considered this, but search service initialization can fail - might be better to Cu.report it here rather than just waiting for subsequent use to fail?
https://hg.mozilla.org/mozilla-central/rev/345a99667b7c
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 32
Status: RESOLVED → VERIFIED
Depends on: 1013722
Depends on: 1014080
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: