Bug 1443870 - update tests for lack of content-process blocklist, r?florian draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 14 Mar 2018 20:02:11 +0000
changeset 768017 6dd067028dc1295f86938730f7b6300d2b488d9c
parent 767352 9249e30ef509d666822f73914de5c52b0a0a477c
child 768038 567f32d1a94b117f3ca3ecd23e324d178b3a8a56
child 768317 29776606e0c1ae833a7667da6d5b914e0d8e1729
child 768318 51e564e4a26bc8c46d83b4f5bec4ccecfeaff59c
child 768797 d7e9797d094542b0bd0aaa72dd82fad1b6e83e50
child 768800 82fcdc6ed8c0b74580cd05e0157a59a16cd39b46
child 768802 25cd0c17cb0b17579d9d10edd394c87a2b1959e6
push id102780
push usergijskruitbosch@gmail.com
push dateThu, 15 Mar 2018 15:54:50 +0000
reviewersflorian
bugs1443870
milestone61.0a1
Bug 1443870 - update tests for lack of content-process blocklist, r?florian MozReview-Commit-ID: 4PyUDd6BNsM
browser/base/content/test/plugins/browser_blocking.js
browser/base/content/test/plugins/browser_blocklist_content.js
browser/base/content/test/plugins/browser_bug743421.js
browser/base/content/test/plugins/browser_bug812562.js
browser/base/content/test/plugins/browser_plugin_reloading.js
browser/base/content/test/plugins/browser_pluginnotification.js
browser/base/content/test/plugins/head.js
--- 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);
 }