Bug 1443870 - update tests for lack of content-process blocklist, r?florian
MozReview-Commit-ID: 4PyUDd6BNsM
--- a/browser/base/content/test/plugins/browser_blocking.js
+++ b/browser/base/content/test/plugins/browser_blocking.js
@@ -27,22 +27,16 @@ add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
// Prime the content process
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>hi</html>");
-
- // Make sure the blocklist service(s) are running
- // eslint-disable-next-line no-unused-expressions
- Services.blocklist;
- let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
- ok(!exmsg, "exception: " + exmsg);
});
// Tests a vulnerable, updatable plugin
add_task(async function() {
// enable hard blocklisting of test
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
--- a/browser/base/content/test/plugins/browser_blocklist_content.js
+++ b/browser/base/content/test/plugins/browser_blocklist_content.js
@@ -24,18 +24,16 @@ add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
- let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
- ok(!exmsg, "exception: " + exmsg);
});
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
// Work around for delayed PluginBindingAttached
--- a/browser/base/content/test/plugins/browser_bug743421.js
+++ b/browser/base/content/test/plugins/browser_bug743421.js
@@ -24,19 +24,16 @@ add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
- let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
- ok(!exmsg, "exception: " + exmsg);
-
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});
// Tests that navigation within the page and the window.history API doesn't break click-to-play state.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_add_dynamically.html");
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
--- a/browser/base/content/test/plugins/browser_bug812562.js
+++ b/browser/base/content/test/plugins/browser_bug812562.js
@@ -16,18 +16,16 @@ add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
- let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
- ok(!exmsg, "exception: " + exmsg);
});
// Tests that the going back will reshow the notification for click-to-play
// blocklisted plugins
add_task(async function() {
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
--- a/browser/base/content/test/plugins/browser_plugin_reloading.js
+++ b/browser/base/content/test/plugins/browser_plugin_reloading.js
@@ -27,18 +27,16 @@ add_task(async function() {
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
- let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
- ok(!exmsg, "exception: " + exmsg);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});
// Tests that a click-to-play plugin retains its activated state upon reloading
add_task(async function() {
clearAllPluginPermissions();
--- a/browser/base/content/test/plugins/browser_pluginnotification.js
+++ b/browser/base/content/test/plugins/browser_pluginnotification.js
@@ -27,18 +27,16 @@ add_task(async function() {
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
- let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
- ok(!exmsg, "exception: " + exmsg);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});
// Tests a page with an unknown plugin in it.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_unknown.html");
--- a/browser/base/content/test/plugins/head.js
+++ b/browser/base/content/test/plugins/head.js
@@ -4,32 +4,16 @@ ChromeUtils.defineModuleGetter(this, "Pl
"resource://gre/modules/PlacesUtils.jsm");
ChromeUtils.defineModuleGetter(this, "PromiseUtils",
"resource://gre/modules/PromiseUtils.jsm");
// Various tests in this directory may define gTestBrowser, to use as the
// default browser under test in some of the functions below.
/* global gTestBrowser */
-// The blocklist shim running in the content process does not initialize at
-// start up, so it's not active until we load content that needs to do a
-// check. This helper bypasses the delay to get the svc up and running
-// immediately. Note, call this after remote content has loaded.
-function promiseInitContentBlocklistSvc(aBrowser) {
- return ContentTask.spawn(aBrowser, {}, async function() {
- try {
- // eslint-disable-next-line no-unused-expressions
- Services.blocklist;
- } catch (ex) {
- return ex.message;
- }
- return null;
- });
-}
-
/**
* Waits a specified number of miliseconds.
*
* Usage:
* let wait = yield waitForMs(2000);
* ok(wait, "2 seconds should now have elapsed");
*
* @param aMs the number of miliseconds to wait for
@@ -232,28 +216,25 @@ function setAndUpdateBlocklist(aURL, aCa
async function asyncSetAndUpdateBlocklist(aURL, aBrowser) {
info("*** loading new blocklist: " + aURL);
let doTestRemote = aBrowser ? aBrowser.isRemoteBrowser : false;
if (!_originalTestBlocklistURL) {
_originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
}
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
let localPromise = TestUtils.topicObserved("blocklist-updated");
- let remotePromise;
- if (doTestRemote) {
- remotePromise = TestUtils.topicObserved("content-blocklist-updated");
- }
let blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
.getService(Ci.nsITimerCallback);
blocklistNotifier.notify(null);
info("*** waiting on local load");
await localPromise;
if (doTestRemote) {
info("*** waiting on remote load");
- await remotePromise;
+ // Ensure content has been updated with the blocklist
+ await ContentTask.spawn(aBrowser, null, () => {});
}
info("*** blocklist loaded.");
}
// Reset back to the blocklist we had at the start of the test run.
function resetBlocklist() {
Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL);
}