bug 816059 - properly reset blocklist in browser-chrome tests r=jaws
authorDavid Keeler <dkeeler@mozilla.com>
Thu, 29 Nov 2012 12:18:53 -0800
changeset 123620 abb39d1df815b6f129d8c512726f8cbc9a85341b
parent 123619 eaf6805d27d68616f357dcd687251234c37c3e26
child 123621 5410bfb11bb5a4c1ae87521e1b3b7dc2fbeb805a
child 123623 9430676f544289b5912bf28c91add86c6758b769
child 126452 0d6694aa229af6b071f4d0de8b739c31573d5e14
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs816059
milestone20.0a1
first release with
nightly linux32
abb39d1df815 / 20.0a1 / 20121130030747 / files
nightly linux64
abb39d1df815 / 20.0a1 / 20121130030747 / files
nightly mac
abb39d1df815 / 20.0a1 / 20121130030747 / files
nightly win32
abb39d1df815 / 20.0a1 / 20121130030747 / files
nightly win64
abb39d1df815 / 20.0a1 / 20121130030747 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 816059 - properly reset blocklist in browser-chrome tests r=jaws
browser/base/content/test/Makefile.in
browser/base/content/test/blockNoPlugins.xml
browser/base/content/test/browser_bug812562.js
browser/base/content/test/browser_pluginnotification.js
browser/base/content/test/head.js
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -267,16 +267,17 @@ endif
                  browser_middleMouse_inherit.js \
                  redirect_bug623155.sjs \
                  browser_tabDrop.js \
                  browser_lastAccessedTab.js \
                  browser_bug734076.js \
                  browser_bug812562.js \
                  blockPluginVulnerableUpdatable.xml \
                  blockPluginVulnerableNoUpdate.xml \
+                 blockNoPlugins.xml \
                  browser_utilityOverlay.js \
                  browser_social.js \
                  browser_social_toolbar.js \
                  browser_social_shareButton.js \
                  browser_social_sidebar.js \
                  browser_social_flyout.js \
                  browser_social_mozSocial_API.js \
                  browser_social_isVisible.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/blockNoPlugins.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310001">
+  <emItems>
+  </emItems>
+  <pluginItems>
+  </pluginItems>
+</blocklist>
--- a/browser/base/content/test/browser_bug812562.js
+++ b/browser/base/content/test/browser_bug812562.js
@@ -20,17 +20,21 @@ function test() {
     prepareTest(testPart1, gHttpTestRoot + "plugin_test.html");
   });
 }
 
 function finishTest() {
   gTestBrowser.removeEventListener("load", pageLoad, true);
   gBrowser.removeCurrentTab();
   window.focus();
-  resetBlocklist(finish);
+  setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml",
+  function() {
+    resetBlocklist();
+    finish();
+  });
 }
 
 function pageLoad(aEvent) {
   // The plugin events are async dispatched and can come after the load event
   // This just allows the events to fire before we then go on to test the states
   if (gNextTest != null)
     executeSoon(gNextTest);
 }
--- a/browser/base/content/test/browser_pluginnotification.js
+++ b/browser/base/content/test/browser_pluginnotification.js
@@ -678,17 +678,19 @@ function test18d() {
 function test18e() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!popupNotification, "Test 18e, Should not have a click-to-play notification");
   var plugin = gTestBrowser.contentDocument.getElementById("test");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 18e, Plugin should be activated");
 
   Services.perms.removeAll();
-  resetBlocklist(function () {
+  setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml",
+  function() {
+    resetBlocklist();
     prepareTest(test19a, gTestRoot + "plugin_test.html");
   });
 }
 
 // Tests that clicking the icon of the overlay activates the plugin
 function test19a() {
   var doc = gTestBrowser.contentDocument;
   var plugin = doc.getElementById("test");
@@ -1052,17 +1054,19 @@ function test24d() {
   var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!notification, "Test 24d, Should not have a click-to-play notification");
   var plugin = gTestBrowser.contentDocument.getElementById("test");
   ok(plugin, "Test 24d, Found plugin in page");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 24d, plugin should be activated");
 
   Services.perms.removeAll();
-  resetBlocklist(function () {
+  setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml",
+  function() {
+    resetBlocklist();
     prepareTest(test25a, gHttpTestRoot + "plugin_test.html");
   });
 }
 
 // Test that clicking "always allow" or "always deny" doesn't affect plugins
 // that already have permission given to them
 function test25a() {
   var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
--- a/browser/base/content/test/head.js
+++ b/browser/base/content/test/head.js
@@ -207,24 +207,26 @@ function updateBlocklist(aCallback) {
   var observer = function() {
     aCallback();
     Services.obs.removeObserver(observer, "blocklist-updated");
   };
   Services.obs.addObserver(observer, "blocklist-updated", false);
   blocklistNotifier.notify(null);
 }
 
+var _originalTestBlocklistURL = null;
 function setAndUpdateBlocklist(aURL, aCallback) {
+  if (!_originalTestBlocklistURL)
+    _originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
   Services.prefs.setCharPref("extensions.blocklist.url", aURL);
   updateBlocklist(aCallback);
 }
 
-function resetBlocklist(aCallback) {
-  Services.prefs.clearUserPref("extensions.blocklist.url");
-  updateBlocklist(aCallback);
+function resetBlocklist() {
+  Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL);
 }
 
 function whenNewWindowLoaded(aOptions, aCallback) {
   let win = OpenBrowserWindow(aOptions);
   win.addEventListener("load", function onLoad() {
     win.removeEventListener("load", onLoad, false);
     aCallback(win);
   }, false);