mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 875949 - 'leaked' provider test cleanup, r=felipe
This commit is contained in:
parent
6727fde3e6
commit
0769e45870
@ -87,9 +87,8 @@ var tests = {
|
||||
is(expectEvent, "onEnabled", "provider onEnabled");
|
||||
ok(!addon.userDisabled, "provider enabled");
|
||||
executeSoon(function() {
|
||||
// restore previous state
|
||||
expectEvent = "onDisabling";
|
||||
addon.userDisabled = !addon.userDisabled;
|
||||
addon.userDisabled = true;
|
||||
});
|
||||
},
|
||||
onEnabling: function(addon) {
|
||||
@ -99,14 +98,10 @@ var tests = {
|
||||
onDisabled: function(addon) {
|
||||
is(expectEvent, "onDisabled", "provider onDisabled");
|
||||
ok(addon.userDisabled, "provider disabled");
|
||||
executeSoon(function() {
|
||||
// restore previous state
|
||||
AddonManager.removeAddonListener(listener);
|
||||
addon.userDisabled = !addon.userDisabled;
|
||||
// clear the provider user-level pref
|
||||
Services.prefs.clearUserPref(prefname);
|
||||
next();
|
||||
});
|
||||
AddonManager.removeAddonListener(listener);
|
||||
// clear the provider user-level pref
|
||||
Services.prefs.clearUserPref(prefname);
|
||||
executeSoon(next);
|
||||
},
|
||||
onDisabling: function(addon) {
|
||||
is(expectEvent, "onDisabling", "provider onDisabling");
|
||||
@ -121,10 +116,12 @@ var tests = {
|
||||
ok(Services.prefs.prefHasUserValue(prefname), "manifest is in user-prefs");
|
||||
AddonManager.getAddonsByTypes([ADDON_TYPE_SERVICE], function(addons) {
|
||||
for (let addon of addons) {
|
||||
expectEvent = addon.userDisabled ? "onEnabling" : "onDisabling";
|
||||
addon.userDisabled = !addon.userDisabled;
|
||||
// only test with one addon
|
||||
return;
|
||||
if (addon.userDisabled) {
|
||||
expectEvent = "onEnabling";
|
||||
addon.userDisabled = false;
|
||||
// only test with one addon
|
||||
return;
|
||||
}
|
||||
}
|
||||
ok(false, "no addons toggled");
|
||||
next();
|
||||
|
@ -21,24 +21,26 @@ function postTestCleanup(callback) {
|
||||
// all providers may have had their manifests added.
|
||||
for (let manifest of gProviders)
|
||||
Services.prefs.clearUserPref("social.manifest." + manifest.origin);
|
||||
|
||||
// all the providers may have been added.
|
||||
let numRemoved = 0;
|
||||
let cbRemoved = function() {
|
||||
if (++numRemoved == gProviders.length) {
|
||||
let providers = gProviders.slice(0)
|
||||
function removeProviders() {
|
||||
if (providers.length < 1) {
|
||||
executeSoon(function() {
|
||||
is(Social.providers.length, 0, "all providers removed");
|
||||
callback();
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (let [i, manifest] of Iterator(gProviders)) {
|
||||
|
||||
let provider = providers.pop();
|
||||
try {
|
||||
SocialService.removeProvider(manifest.origin, cbRemoved);
|
||||
SocialService.removeProvider(provider.origin, removeProviders);
|
||||
} catch(ex) {
|
||||
// this test didn't add this provider - that's ok.
|
||||
cbRemoved();
|
||||
removeProviders();
|
||||
}
|
||||
}
|
||||
removeProviders();
|
||||
}
|
||||
|
||||
function addBuiltinManifest(manifest) {
|
||||
@ -268,7 +270,7 @@ var tests = {
|
||||
Social.provider = Social.providers[1];
|
||||
checkSocialUI();
|
||||
// activate the last provider.
|
||||
addBuiltinManifest(gProviders[2]);
|
||||
let prefname = addBuiltinManifest(gProviders[2]);
|
||||
activateProvider(gTestDomains[2], function() {
|
||||
waitForProviderLoad(function() {
|
||||
ok(!SocialUI.activationPanel.hidden, "activation panel is showing");
|
||||
@ -284,6 +286,7 @@ var tests = {
|
||||
is(Social.provider.origin, Social.providers[1].origin, "original provider still be active");
|
||||
checkSocialUI();
|
||||
Services.prefs.clearUserPref("social.whitelist");
|
||||
resetBuiltinManifestPref(prefname);
|
||||
next();
|
||||
});
|
||||
});
|
||||
@ -306,7 +309,7 @@ var tests = {
|
||||
let browser = blanktab.linkedBrowser;
|
||||
is(browser.currentURI.spec, "about:addons", "about:addons should load into blank tab.");
|
||||
|
||||
addBuiltinManifest(gProviders[0]);
|
||||
let prefname = addBuiltinManifest(gProviders[0]);
|
||||
activateOneProvider(gProviders[0], true, function() {
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
tabsToRemove.pop();
|
||||
@ -321,6 +324,7 @@ var tests = {
|
||||
AddonManager.getAddonsByTypes(["service"], function(aAddons) {
|
||||
is(aAddons.length, 1, "there can be only one");
|
||||
Services.prefs.clearUserPref("social.whitelist");
|
||||
resetBuiltinManifestPref(prefname);
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
@ -40,6 +40,26 @@ function promiseSocialUrlNotRemembered(url) {
|
||||
|
||||
let gURLsNotRemembered = [];
|
||||
|
||||
|
||||
function checkProviderPrefsEmpty(isError) {
|
||||
let MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
|
||||
let prefs = MANIFEST_PREFS.getChildList("", []);
|
||||
let c = 0;
|
||||
for (let pref of prefs) {
|
||||
if (MANIFEST_PREFS.prefHasUserValue(pref)) {
|
||||
info("provider [" + pref + "] manifest left installed from previous test");
|
||||
c++;
|
||||
}
|
||||
}
|
||||
is(c, 0, "all provider prefs uninstalled from previous test");
|
||||
is(Social.providers.length, 0, "all providers uninstalled from previous test " + Social.providers.length);
|
||||
}
|
||||
|
||||
function defaultFinishChecks() {
|
||||
checkProviderPrefsEmpty(true);
|
||||
finish();
|
||||
}
|
||||
|
||||
function runSocialTestWithProvider(manifest, callback, finishcallback) {
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
@ -67,7 +87,7 @@ function runSocialTestWithProvider(manifest, callback, finishcallback) {
|
||||
function finishIfDone(callFinish) {
|
||||
finishCount++;
|
||||
if (finishCount == manifests.length)
|
||||
Task.spawn(finishCleanUp).then(finishcallback || finish);
|
||||
Task.spawn(finishCleanUp).then(finishcallback || defaultFinishChecks);
|
||||
}
|
||||
function removeAddedProviders(cleanup) {
|
||||
manifests.forEach(function (m) {
|
||||
@ -128,6 +148,7 @@ function runSocialTestWithProvider(manifest, callback, finishcallback) {
|
||||
|
||||
function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
|
||||
let testIter = Iterator(tests);
|
||||
let providersAtStart = Social.providers.length;
|
||||
|
||||
if (cbPreTest === undefined) {
|
||||
cbPreTest = function(cb) {cb()};
|
||||
@ -142,7 +163,7 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
|
||||
[name, func] = testIter.next();
|
||||
} catch (err if err instanceof StopIteration) {
|
||||
// out of items:
|
||||
(cbFinish || finish)();
|
||||
(cbFinish || defaultFinishChecks)();
|
||||
return;
|
||||
}
|
||||
// We run on a timeout as the frameworker also makes use of timeouts, so
|
||||
@ -153,6 +174,7 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
|
||||
cbPostTest(runNextTest);
|
||||
}
|
||||
cbPreTest(function() {
|
||||
is(providersAtStart, Social.providers.length, "no new providers left enabled");
|
||||
info("sub-test " + name + " starting");
|
||||
try {
|
||||
func.call(tests, cleanupAndRunNextTest);
|
||||
|
Loading…
Reference in New Issue
Block a user