Backed out changeset 080912624060 (bug 869209) for Android xpcshell failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sat, 11 May 2013 08:14:34 -0400
changeset 142588 390d49fe8290d8d05207e438b2c60b521b829bee
parent 142587 7a00d25b5012c97365dd6ac9d321489c738a1ef3
child 142589 aa2ce091b9fe5a2ee4d06b512165495a25aa0cf0
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs869209
milestone23.0a1
backs out080912624060eda81594ce2c342b35d9a93767b5
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
Backed out changeset 080912624060 (bug 869209) for Android xpcshell failures. CLOSED TREE
browser/modules/Social.jsm
toolkit/components/social/SocialService.jsm
toolkit/components/social/test/xpcshell/head.js
toolkit/components/social/test/xpcshell/test_SocialService.js
--- a/browser/modules/Social.jsm
+++ b/browser/modules/Social.jsm
@@ -147,17 +147,17 @@ this.Social = {
     this._disabledForSafeMode = Services.appinfo.inSafeMode && this.enabled;
 
     if (this.initialized) {
       return;
     }
     this.initialized = true;
 
     // Retrieve the current set of providers, and set the current provider.
-    SocialService.getOrderedProviderList(function (providers) {
+    SocialService.getProviderList(function (providers) {
       this._updateProviderCache(providers);
     }.bind(this));
 
     // Register an observer for changes to the provider list
     SocialService.registerProviderListener(function providerListener(topic, data) {
       // An engine change caused by adding/removing a provider should notify
       if (topic == "provider-added" || topic == "provider-removed") {
         this._updateProviderCache(data);
--- a/toolkit/components/social/SocialService.jsm
+++ b/toolkit/components/social/SocialService.jsm
@@ -4,32 +4,27 @@
 
 this.EXPORTED_SYMBOLS = ["SocialService"];
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/AddonManager.jsm");
-Cu.import("resource://gre/modules/PlacesUtils.jsm");
 
 const URI_EXTENSION_STRINGS  = "chrome://mozapps/locale/extensions/extensions.properties";
 const ADDON_TYPE_SERVICE     = "service";
 const ID_SUFFIX              = "@services.mozilla.org";
 const STRING_TYPE_NAME       = "type.%ID%.name";
 
 XPCOMUtils.defineLazyModuleGetter(this, "getFrameWorkerHandle", "resource://gre/modules/FrameWorker.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "WorkerAPI", "resource://gre/modules/WorkerAPI.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MozSocialAPI", "resource://gre/modules/MozSocialAPI.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm");
 
-XPCOMUtils.defineLazyServiceGetter(this, "etld",
-                                   "@mozilla.org/network/effective-tld-service;1",
-                                   "nsIEffectiveTLDService");
-
 /**
  * The SocialService is the public API to social providers - it tracks which
  * providers are installed and enabled, and is the entry-point for access to
  * the provider itself.
  */
 
 // Internal helper methods and state
 let SocialServiceInternal = {
@@ -76,69 +71,16 @@ let SocialServiceInternal = {
         }
       } catch (err) {
         Cu.reportError("SocialService: failed to load manifest: " + pref +
                        ", exception: " + err);
       }
     }
     let originUri = Services.io.newURI(origin, null, null);
     return originUri.hostPort.replace('.','-');
-  },
-  orderedProviders: function(aCallback) {
-    if (SocialServiceInternal.providerArray.length < 2) {
-      schedule(function () {
-        aCallback(SocialServiceInternal.providerArray);
-      });
-      return;
-    }
-    // query moz_hosts for frecency.  since some providers may not have a
-    // frecency entry, we need to later sort on our own. We use the providers
-    // object below as an easy way to later record the frecency on the provider
-    // object from the query results.
-    let hosts = [];
-    let providers = {};
-
-    for (p of SocialServiceInternal.providerArray) {
-      p.frecency = 0;
-      providers[p.domain] = p;
-      hosts.push(p.domain);
-    };
-
-    // cannot bind an array to stmt.params so we have to build the string
-    let stmt = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
-                                 .DBConnection.createAsyncStatement(
-      "SELECT host, frecency FROM moz_hosts WHERE host IN (" +
-      [ '"' + host + '"' for each (host in hosts) ].join(",") + ") "
-    );
-
-    try {
-      stmt.executeAsync({
-        handleResult: function(aResultSet) {
-          let row;
-          while ((row = aResultSet.getNextRow())) {
-            let rh = row.getResultByName("host");
-            let frecency = row.getResultByName("frecency");
-            providers[rh].frecency = parseInt(frecency) || 0;
-          }
-        },
-        handleError: function(aError) {
-          Cu.reportError(aError.message + " (Result = " + aError.result + ")");
-        },
-        handleCompletion: function(aReason) {
-          // the query may not have returned all our providers, so we have
-          // stamped the frecency on the provider and sort here. This makes sure
-          // all enabled providers get sorted even with frecency zero.
-          let providerList = SocialServiceInternal.providerArray;
-          // reverse sort
-          aCallback(providerList.sort(function(a, b) b.frecency - a.frecency));
-        }
-      });
-    } finally {
-      stmt.finalize();
-    }
   }
 };
 
 let ActiveProviders = {
   get _providers() {
     delete this._providers;
     this._providers = {};
     try {
@@ -378,18 +320,19 @@ this.SocialService = {
   addProvider: function addProvider(manifest, onDone) {
     if (SocialServiceInternal.providers[manifest.origin])
       throw new Error("SocialService.addProvider: provider with this origin already exists");
 
     let provider = new SocialProvider(manifest);
     SocialServiceInternal.providers[provider.origin] = provider;
     ActiveProviders.add(provider.origin);
 
-    this.getOrderedProviderList(function (providers) {
-      this._notifyProviderListeners("provider-added", providers);
+    schedule(function () {
+      this._notifyProviderListeners("provider-added",
+                                    SocialServiceInternal.providerArray);
       if (onDone)
         onDone(provider);
     }.bind(this));
   },
 
   // Removes a provider with the given origin, and notifies when the removal is
   // complete.
   removeProvider: function removeProvider(origin, onDone) {
@@ -412,43 +355,39 @@ this.SocialService = {
     if (addon) {
       // we have to do this now so the addon manager ui will update an uninstall
       // correctly.
       addon.pendingOperations -= AddonManager.PENDING_DISABLE;
       AddonManagerPrivate.callAddonListeners("onDisabled", addon);
       AddonManagerPrivate.notifyAddonChanged(addon.id, ADDON_TYPE_SERVICE, false);
     }
 
-    this.getOrderedProviderList(function (providers) {
-      this._notifyProviderListeners("provider-removed", providers);
+    schedule(function () {
+      this._notifyProviderListeners("provider-removed",
+                                    SocialServiceInternal.providerArray);
       if (onDone)
         onDone();
     }.bind(this));
   },
 
   // Returns a single provider object with the specified origin.  The provider
   // must be "installed" (ie, in ActiveProviders)
   getProvider: function getProvider(origin, onDone) {
     schedule((function () {
       onDone(SocialServiceInternal.providers[origin] || null);
     }).bind(this));
   },
 
-  // Returns an unordered array of installed providers
-  getProviderList: function(onDone) {
+  // Returns an array of installed providers.
+  getProviderList: function getProviderList(onDone) {
     schedule(function () {
       onDone(SocialServiceInternal.providerArray);
     });
   },
 
-  // Returns an array of installed providers, sorted by frecency
-  getOrderedProviderList: function(onDone) {
-    SocialServiceInternal.orderedProviders(onDone);
-  },
-
   getOriginActivationType: function(origin) {
     let prefname = SocialServiceInternal.getManifestPrefname(origin);
     if (Services.prefs.getDefaultBranch("social.manifest.").getPrefType(prefname) == Services.prefs.PREF_STRING)
       return 'builtin';
 
     let whitelist = Services.prefs.getCharPref("social.whitelist").split(',');
     if (whitelist.indexOf(origin) >= 0)
       return 'whitelist';
@@ -668,22 +607,16 @@ function SocialProvider(input) {
   this.workerURL = input.workerURL;
   this.sidebarURL = input.sidebarURL;
   this.shareURL = input.shareURL;
   this.origin = input.origin;
   let originUri = Services.io.newURI(input.origin, null, null);
   this.principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(originUri);
   this.ambientNotificationIcons = {};
   this.errorState = null;
-  this.frecency = 0;
-  try {
-    this.domain = etld.getBaseDomainFromHost(originUri.host);
-  } catch(e) {
-    this.domain = originUri.host;
-  }
 }
 
 SocialProvider.prototype = {
   // Provider enabled/disabled state. Disabled providers do not have active
   // connections to their FrameWorkers.
   _enabled: false,
   get enabled() {
     return this._enabled;
--- a/toolkit/components/social/test/xpcshell/head.js
+++ b/toolkit/components/social/test/xpcshell/head.js
@@ -1,21 +1,16 @@
 /* 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 { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "Promise",
-  "resource://gre/modules/commonjs/sdk/core/promise.js");
-XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
-  "resource://gre/modules/PlacesUtils.jsm");
-
 const MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
 const gProfD = do_get_profile();
 
 const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
 const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
 
 function createAppInfo(id, name, version, platformVersion) {
   gAppInfo = {
@@ -150,73 +145,8 @@ AsyncRunner.prototype = {
     this.destroy = function alreadyDestroyed() {};
   },
 
   observe: function observe(msg) {
     if (msg instanceof Ci.nsIScriptError)
       this._callbacks.consoleError(msg);
   },
 };
-
-
-function promiseAddVisits(aPlaceInfo)
-{
-  let deferred = Promise.defer();
-  let places = [];
-  if (aPlaceInfo instanceof Ci.nsIURI) {
-    places.push({ uri: aPlaceInfo });
-  }
-  else if (Array.isArray(aPlaceInfo)) {
-    places = places.concat(aPlaceInfo);
-  } else {
-    places.push(aPlaceInfo)
-  }
-
-  // Create mozIVisitInfo for each entry.
-  let now = Date.now();
-  for (let i = 0; i < places.length; i++) {
-    if (!places[i].title) {
-      places[i].title = "test visit for " + places[i].uri.spec;
-    }
-    places[i].visits = [{
-      transitionType: places[i].transition === undefined ? Ci.nsINavHistoryService.TRANSITION_LINK
-                                                         : places[i].transition,
-      visitDate: places[i].visitDate || (now++) * 1000,
-      referrerURI: places[i].referrer
-    }];
-  }
-
-  PlacesUtils.asyncHistory.updatePlaces(
-    places,
-    {
-      handleError: function handleError(aResultCode, aPlaceInfo) {
-        let ex = new Components.Exception("Unexpected error in adding visits.",
-                                          aResultCode);
-        deferred.reject(ex);
-      },
-      handleResult: function () {},
-      handleCompletion: function handleCompletion() {
-        deferred.resolve();
-      }
-    }
-  );
-
-  return deferred.promise;
-}
-
-function promiseTopicObserved(aTopic)
-{
-  let deferred = Promise.defer();
-
-  Services.obs.addObserver(
-    function PTO_observe(aSubject, aTopic, aData) {
-      Services.obs.removeObserver(PTO_observe, aTopic);
-      deferred.resolve([aSubject, aData]);
-    }, aTopic, false);
-
-  return deferred.promise;
-}
-
-function promiseClearHistory() {
-  let promise = promiseTopicObserved(PlacesUtils.TOPIC_EXPIRATION_FINISHED);
-  do_execute_soon(function() PlacesUtils.bhistory.removeAllPages());
-  return promise;
-}
--- a/toolkit/components/social/test/xpcshell/test_SocialService.js
+++ b/toolkit/components/social/test/xpcshell/test_SocialService.js
@@ -1,30 +1,27 @@
 /* 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/. */
 
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/PlacesUtils.jsm");
 
 function run_test() {
   initApp();
 
   // NOTE: none of the manifests here can have a workerURL set, or we attempt
   // to create a FrameWorker and that fails under xpcshell...
   let manifests = [
     { // normal provider
       name: "provider 1",
       origin: "https://example1.com",
-      sidebarURL: "https://example1.com/sidebar/",
     },
     { // provider without workerURL
       name: "provider 2",
-      origin: "https://example2.com",
-      sidebarURL: "https://example2.com/sidebar/",
+      origin: "https://example2.com"
     }
   ];
 
   manifests.forEach(function (manifest) {
     MANIFEST_PREFS.setCharPref(manifest.origin, JSON.stringify(manifest));
   });
   // Set both providers active and flag the first one as "current"
   let activeVal = Cc["@mozilla.org/supports-string;1"].
@@ -44,17 +41,16 @@ function run_test() {
   let runner = new AsyncRunner();
   let next = runner.next.bind(runner);
   runner.appendIterator(testGetProvider(manifests, next));
   runner.appendIterator(testGetProviderList(manifests, next));
   runner.appendIterator(testEnabled(manifests, next));
   runner.appendIterator(testAddRemoveProvider(manifests, next));
   runner.appendIterator(testIsSameOrigin(manifests, next));
   runner.appendIterator(testResolveUri  (manifests, next));
-  runner.appendIterator(testOrderedProviders(manifests, next));
   runner.next();
 }
 
 function testGetProvider(manifests, next) {
   for (let i = 0; i < manifests.length; i++) {
     let manifest = manifests[i];
     let provider = yield SocialService.getProvider(manifest.origin, next);
     do_check_neq(provider, null);
@@ -167,31 +163,8 @@ function testResolveUri(manifests, next)
   let providers = yield SocialService.getProviderList(next);
   let provider = providers[0];
   do_check_eq(provider.resolveUri(provider.origin).spec, provider.origin + "/");
   do_check_eq(provider.resolveUri("foo.html").spec, provider.origin + "/foo.html");
   do_check_eq(provider.resolveUri("/foo.html").spec, provider.origin + "/foo.html");
   do_check_eq(provider.resolveUri("http://somewhereelse.com/foo.html").spec, "http://somewhereelse.com/foo.html");
   do_check_eq(provider.resolveUri("data:text/html,<p>hi").spec, "data:text/html,<p>hi");
 }
-
-function testOrderedProviders(manifests, next) {
-  let providers = yield SocialService.getProviderList(next);
-
-  // add visits for only one of the providers
-  let visits = [];
-  let startDate = Date.now() * 1000;
-  for (let i = 0; i < 10; i++) {
-    visits.push({
-      uri: Services.io.newURI(providers[1].sidebarURL + i, null, null),
-      visitDate: startDate + i
-    });
-  }
-
-  promiseAddVisits(visits).then(next);
-  yield;
-  let orderedProviders = yield SocialService.getOrderedProviderList(next);
-  do_check_eq(orderedProviders[0], providers[1]);
-  do_check_eq(orderedProviders[1], providers[0]);
-  do_check_true(orderedProviders[0].frecency > orderedProviders[1].frecency);
-  promiseClearHistory().then(next);
-  yield;
-}