Bug 1363443 - Use Cu.isModuleLoaded to see if the module is loaded in PlacesCategoriesStarter.js. r=mak draft
authorAndrew McCreight <continuation@gmail.com>
Mon, 08 May 2017 14:56:18 -0700
changeset 574985 44a4d2bd18b3a735b630492b816e5b2f215f1702
parent 574984 6b06280eec0808d21f0e887aaf920a35ed59eaa6
child 627757 5ec039ecb601b79c1d7d0f5f6924e8e18d7b711c
push id57879
push userbmo:continuation@gmail.com
push dateTue, 09 May 2017 17:19:19 +0000
reviewersmak
bugs1363443, 1186409
milestone55.0a1
Bug 1363443 - Use Cu.isModuleLoaded to see if the module is loaded in PlacesCategoriesStarter.js. r=mak Cu.isModuleLoaded is more direct, and also the current method will break if jsms begin to share globals, as in bug 1186409. This patch is by billm from bug 1186409. MozReview-Commit-ID: KoHMTJpmHg2
toolkit/components/places/PlacesCategoriesStarter.js
--- a/toolkit/components/places/PlacesCategoriesStarter.js
+++ b/toolkit/components/places/PlacesCategoriesStarter.js
@@ -57,21 +57,17 @@ function PlacesCategoriesStarter() {
 PlacesCategoriesStarter.prototype = {
   // nsIObserver
 
   observe: function PCS_observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case PlacesUtils.TOPIC_SHUTDOWN:
         Services.obs.removeObserver(this, PlacesUtils.TOPIC_SHUTDOWN);
         Services.obs.removeObserver(this, TOPIC_GATHER_TELEMETRY);
-        let globalObj =
-          Cu.getGlobalForObject(PlacesCategoriesStarter.prototype);
-        let descriptor =
-          Object.getOwnPropertyDescriptor(globalObj, "PlacesDBUtils");
-        if (descriptor.value !== undefined) {
+        if (Cu.isModuleLoaded("resource://gre/modules/PlacesDBUtils.jsm")) {
           PlacesDBUtils.shutdown();
         }
         break;
       case TOPIC_GATHER_TELEMETRY:
         PlacesDBUtils.telemetry();
         break;
       case "idle-daily":
         // Once a week run places.sqlite maintenance tasks.