mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 963961 fix intermittent blocklist failure, r=felipe
This commit is contained in:
parent
a18c031e95
commit
0b4eb0c893
@ -7,7 +7,7 @@
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
|
||||
let blocklistURL = "http://example.org/browser/browser/base/content/test/social/blocklist.xml";
|
||||
let blocklistURL = "http://example.com/browser/browser/base/content/test/social/blocklist.xml";
|
||||
|
||||
let manifest = { // normal provider
|
||||
name: "provider ok",
|
||||
@ -26,6 +26,11 @@ let manifest_bad = { // normal provider
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
// turn on logging for nsBlocklistService.js
|
||||
Services.prefs.setBoolPref("extensions.logging.enabled", true);
|
||||
registerCleanupFunction(function () {
|
||||
Services.prefs.clearUserPref("extensions.logging.enabled");
|
||||
});
|
||||
|
||||
runSocialTests(tests, undefined, undefined, function () {
|
||||
resetBlocklist(finish); //restore to original pref
|
||||
@ -45,7 +50,7 @@ var tests = {
|
||||
});
|
||||
},
|
||||
testAddingNonBlockedProvider: function(next) {
|
||||
function finish(isgood) {
|
||||
function finishTest(isgood) {
|
||||
ok(isgood, "adding non-blocked provider ok");
|
||||
Services.prefs.clearUserPref("social.manifest.good");
|
||||
resetBlocklist(next);
|
||||
@ -57,21 +62,21 @@ var tests = {
|
||||
try {
|
||||
SocialService.removeProvider(provider.origin, function() {
|
||||
ok(true, "added and removed provider");
|
||||
finish(true);
|
||||
finishTest(true);
|
||||
});
|
||||
} catch(e) {
|
||||
ok(false, "SocialService.removeProvider threw exception: " + e);
|
||||
finish(false);
|
||||
finishTest(false);
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
ok(false, "SocialService.addProvider threw exception: " + e);
|
||||
finish(false);
|
||||
finishTest(false);
|
||||
}
|
||||
});
|
||||
},
|
||||
testAddingBlockedProvider: function(next) {
|
||||
function finish(good) {
|
||||
function finishTest(good) {
|
||||
ok(good, "Unable to add blocklisted provider");
|
||||
Services.prefs.clearUserPref("social.manifest.blocked");
|
||||
resetBlocklist(next);
|
||||
@ -80,17 +85,19 @@ var tests = {
|
||||
setAndUpdateBlocklist(blocklistURL, function() {
|
||||
try {
|
||||
SocialService.addProvider(manifest_bad, function(provider) {
|
||||
ok(false, "SocialService.addProvider should throw blocklist exception");
|
||||
finish(false);
|
||||
SocialService.removeProvider(provider.origin, function() {
|
||||
ok(false, "SocialService.addProvider should throw blocklist exception");
|
||||
finishTest(false);
|
||||
});
|
||||
});
|
||||
} catch(e) {
|
||||
ok(true, "SocialService.addProvider should throw blocklist exception: " + e);
|
||||
finish(true);
|
||||
finishTest(true);
|
||||
}
|
||||
});
|
||||
},
|
||||
testInstallingBlockedProvider: function(next) {
|
||||
function finish(good) {
|
||||
function finishTest(good) {
|
||||
ok(good, "Unable to add blocklisted provider");
|
||||
Services.prefs.clearUserPref("social.whitelist");
|
||||
resetBlocklist(next);
|
||||
@ -108,24 +115,16 @@ var tests = {
|
||||
// provider
|
||||
Social.installProvider(doc, manifest_bad, function(addonManifest) {
|
||||
gBrowser.removeTab(tab);
|
||||
finish(false);
|
||||
finishTest(false);
|
||||
});
|
||||
} catch(e) {
|
||||
gBrowser.removeTab(tab);
|
||||
finish(true);
|
||||
finishTest(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
testBlockingExistingProvider: function(next) {
|
||||
let windowWasClosed = false;
|
||||
function finish() {
|
||||
waitForCondition(function() windowWasClosed, function() {
|
||||
Services.wm.removeListener(listener);
|
||||
next();
|
||||
}, "blocklist dialog was closed");
|
||||
}
|
||||
|
||||
let listener = {
|
||||
_window: null,
|
||||
onOpenWindow: function(aXULWindow) {
|
||||
@ -140,12 +139,18 @@ var tests = {
|
||||
domwindow.addEventListener("unload", function _unload() {
|
||||
domwindow.removeEventListener("unload", _unload, false);
|
||||
info("blocklist window was closed");
|
||||
windowWasClosed = true;
|
||||
Services.wm.removeListener(listener);
|
||||
next();
|
||||
}, false);
|
||||
|
||||
is(domwindow.document.location.href, URI_EXTENSION_BLOCKLIST_DIALOG, "dialog opened and focused");
|
||||
domwindow.close();
|
||||
|
||||
// wait until after load to cancel so the dialog has initalized. we
|
||||
// don't want to accept here since that restarts the browser.
|
||||
executeSoon(() => {
|
||||
let cancelButton = domwindow.document.documentElement.getButton("cancel");
|
||||
info("***** hit the cancel button\n");
|
||||
cancelButton.doCommand();
|
||||
});
|
||||
}, false);
|
||||
},
|
||||
onCloseWindow: function(aXULWindow) { },
|
||||
@ -167,7 +172,7 @@ var tests = {
|
||||
SocialService.getProvider(provider.origin, function(p) {
|
||||
ok(p == null, "blocklisted provider disabled");
|
||||
Services.prefs.clearUserPref("social.manifest.blocked");
|
||||
resetBlocklist(finish);
|
||||
resetBlocklist();
|
||||
});
|
||||
});
|
||||
// no callback - the act of updating should cause the listener above
|
||||
@ -176,7 +181,7 @@ var tests = {
|
||||
});
|
||||
} catch(e) {
|
||||
ok(false, "unable to add provider " + e);
|
||||
finish();
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,6 +273,7 @@ function Blocklist() {
|
||||
gBlocklistLevel = Math.min(getPref("getIntPref", PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL),
|
||||
MAX_BLOCK_LEVEL);
|
||||
gPref.addObserver("extensions.blocklist.", this, false);
|
||||
gPref.addObserver(PREF_EM_LOGGING_ENABLED, this, false);
|
||||
}
|
||||
|
||||
Blocklist.prototype = {
|
||||
@ -300,9 +301,13 @@ Blocklist.prototype = {
|
||||
let os = getObserverService();
|
||||
os.removeObserver(this, "xpcom-shutdown");
|
||||
gPref.removeObserver("extensions.blocklist.", this);
|
||||
gPref.removeObserver(PREF_EM_LOGGING_ENABLED, this);
|
||||
break;
|
||||
case "nsPref:changed":
|
||||
switch (aData) {
|
||||
case PREF_EM_LOGGING_ENABLED:
|
||||
gLoggingEnabled = getPref("getBoolPref", PREF_EM_LOGGING_ENABLED, false);
|
||||
break;
|
||||
case PREF_BLOCKLIST_ENABLED:
|
||||
gBlocklistEnabled = getPref("getBoolPref", PREF_BLOCKLIST_ENABLED, true);
|
||||
this._loadBlocklist();
|
||||
|
Loading…
Reference in New Issue
Block a user