Backed out changeset 080912624060 (bug 869209) for Android xpcshell failures.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2013-05-11 08:14:34 -04:00
Родитель 84d7ae8527
Коммит 5bb2d127c8
4 изменённых файлов: 10 добавлений и 174 удалений

Просмотреть файл

@ -152,7 +152,7 @@ this.Social = {
this.initialized = true; this.initialized = true;
// Retrieve the current set of providers, and set the current provider. // Retrieve the current set of providers, and set the current provider.
SocialService.getOrderedProviderList(function (providers) { SocialService.getProviderList(function (providers) {
this._updateProviderCache(providers); this._updateProviderCache(providers);
}.bind(this)); }.bind(this));

Просмотреть файл

@ -9,7 +9,6 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/AddonManager.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 URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
const ADDON_TYPE_SERVICE = "service"; const ADDON_TYPE_SERVICE = "service";
@ -21,10 +20,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "WorkerAPI", "resource://gre/modules/Wor
XPCOMUtils.defineLazyModuleGetter(this, "MozSocialAPI", "resource://gre/modules/MozSocialAPI.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "MozSocialAPI", "resource://gre/modules/MozSocialAPI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.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 * 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 * providers are installed and enabled, and is the entry-point for access to
@ -81,59 +76,6 @@ let SocialServiceInternal = {
} }
let originUri = Services.io.newURI(origin, null, null); let originUri = Services.io.newURI(origin, null, null);
return originUri.hostPort.replace('.','-'); 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();
}
} }
}; };
@ -383,8 +325,9 @@ this.SocialService = {
SocialServiceInternal.providers[provider.origin] = provider; SocialServiceInternal.providers[provider.origin] = provider;
ActiveProviders.add(provider.origin); ActiveProviders.add(provider.origin);
this.getOrderedProviderList(function (providers) { schedule(function () {
this._notifyProviderListeners("provider-added", providers); this._notifyProviderListeners("provider-added",
SocialServiceInternal.providerArray);
if (onDone) if (onDone)
onDone(provider); onDone(provider);
}.bind(this)); }.bind(this));
@ -417,8 +360,9 @@ this.SocialService = {
AddonManagerPrivate.notifyAddonChanged(addon.id, ADDON_TYPE_SERVICE, false); AddonManagerPrivate.notifyAddonChanged(addon.id, ADDON_TYPE_SERVICE, false);
} }
this.getOrderedProviderList(function (providers) { schedule(function () {
this._notifyProviderListeners("provider-removed", providers); this._notifyProviderListeners("provider-removed",
SocialServiceInternal.providerArray);
if (onDone) if (onDone)
onDone(); onDone();
}.bind(this)); }.bind(this));
@ -432,18 +376,13 @@ this.SocialService = {
}).bind(this)); }).bind(this));
}, },
// Returns an unordered array of installed providers // Returns an array of installed providers.
getProviderList: function(onDone) { getProviderList: function getProviderList(onDone) {
schedule(function () { schedule(function () {
onDone(SocialServiceInternal.providerArray); onDone(SocialServiceInternal.providerArray);
}); });
}, },
// Returns an array of installed providers, sorted by frecency
getOrderedProviderList: function(onDone) {
SocialServiceInternal.orderedProviders(onDone);
},
getOriginActivationType: function(origin) { getOriginActivationType: function(origin) {
let prefname = SocialServiceInternal.getManifestPrefname(origin); let prefname = SocialServiceInternal.getManifestPrefname(origin);
if (Services.prefs.getDefaultBranch("social.manifest.").getPrefType(prefname) == Services.prefs.PREF_STRING) if (Services.prefs.getDefaultBranch("social.manifest.").getPrefType(prefname) == Services.prefs.PREF_STRING)
@ -673,12 +612,6 @@ function SocialProvider(input) {
this.principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(originUri); this.principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(originUri);
this.ambientNotificationIcons = {}; this.ambientNotificationIcons = {};
this.errorState = null; this.errorState = null;
this.frecency = 0;
try {
this.domain = etld.getBaseDomainFromHost(originUri.host);
} catch(e) {
this.domain = originUri.host;
}
} }
SocialProvider.prototype = { SocialProvider.prototype = {

Просмотреть файл

@ -6,11 +6,6 @@ const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.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 MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
const gProfD = do_get_profile(); const gProfD = do_get_profile();
@ -155,68 +150,3 @@ AsyncRunner.prototype = {
this._callbacks.consoleError(msg); 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;
}

Просмотреть файл

@ -3,7 +3,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PlacesUtils.jsm");
function run_test() { function run_test() {
initApp(); initApp();
@ -14,12 +13,10 @@ function run_test() {
{ // normal provider { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example1.com", origin: "https://example1.com",
sidebarURL: "https://example1.com/sidebar/",
}, },
{ // provider without workerURL { // provider without workerURL
name: "provider 2", name: "provider 2",
origin: "https://example2.com", origin: "https://example2.com"
sidebarURL: "https://example2.com/sidebar/",
} }
]; ];
@ -49,7 +46,6 @@ function run_test() {
runner.appendIterator(testAddRemoveProvider(manifests, next)); runner.appendIterator(testAddRemoveProvider(manifests, next));
runner.appendIterator(testIsSameOrigin(manifests, next)); runner.appendIterator(testIsSameOrigin(manifests, next));
runner.appendIterator(testResolveUri (manifests, next)); runner.appendIterator(testResolveUri (manifests, next));
runner.appendIterator(testOrderedProviders(manifests, next));
runner.next(); runner.next();
} }
@ -172,26 +168,3 @@ function testResolveUri(manifests, next) {
do_check_eq(provider.resolveUri("http://somewhereelse.com/foo.html").spec, "http://somewhereelse.com/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"); 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;
}