bug 821098 - browser_pluginnotification.js should not call Services.perms.removeAll() r=jaws
authorDavid Keeler <dkeeler@mozilla.com>
Mon, 17 Dec 2012 14:07:53 -0800
changeset 121897 821ceb9e268790bf04bdad54bd7e08cd04f2e376
parent 121896 94bf149c73a374ad143f3f5e01bebb15f131525e
child 121898 6493a073d5ca4f37cb094d3c0d175a338c2a4d42
push idunknown
push userunknown
push dateunknown
reviewersjaws
bugs821098
milestone20.0a1
bug 821098 - browser_pluginnotification.js should not call Services.perms.removeAll() r=jaws
browser/base/content/test/browser_pluginnotification.js
--- a/browser/base/content/test/browser_pluginnotification.js
+++ b/browser/base/content/test/browser_pluginnotification.js
@@ -1,16 +1,17 @@
 var rootDir = getRootDirectory(gTestPath);
 const gTestRoot = rootDir;
 const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
 
 var gTestBrowser = null;
 var gNextTest = null;
 var gClickToPlayPluginActualEvents = 0;
 var gClickToPlayPluginExpectedEvents = 5;
+var gPluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 // This listens for the next opened tab and checks it is of the right url.
 // opencallback is called when the new tab is fully loaded
 // closecallback is called when the tab is closed
 function TabOpenListener(url, opencallback, closecallback) {
   this.url = url;
@@ -415,17 +416,17 @@ function test12d() {
   var secondtestB = gTestBrowser.contentDocument.getElementById("secondtestB");
   var objLoadingContent = test.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 12d, Test plugin should be activated");
   var objLoadingContent = secondtestA.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Test 12d, Second Test plugin (A) should not be activated");
   var objLoadingContent = secondtestB.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Test 12d, Second Test plugin (B) should not be activated");
 
-  Services.perms.removeAll();
+  Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test"));
   prepareTest(test13a, gHttpTestRoot + "plugin_clickToPlayDeny.html");
 }
 
 // Tests that the "Deny Always" permission works for click-to-play plugins (part 1/3)
 function test13a() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(popupNotification, "Test 13a, Should have a click-to-play notification");
   var plugin = gTestBrowser.contentDocument.getElementById("test");
@@ -505,31 +506,30 @@ function test13e() {
   var secondtestA = gTestBrowser.contentDocument.getElementById("secondtestA");
   var objLoadingContent = secondtestA.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 13e, Second Test plugin (A) should be activated");
 
   var secondtestB = gTestBrowser.contentDocument.getElementById("secondtestB");
   var objLoadingContent = secondtestB.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 13e, Second Test plugin (B) should be activated");
 
-  Services.perms.removeAll();
+  Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test"));
   Services.prefs.setBoolPref("plugins.click_to_play", false);
   prepareTest(test14, gTestRoot + "plugin_test2.html");
 }
 
 // Tests that the plugin's "activated" property is true for working plugins with click-to-play disabled.
 function test14() {
   var plugin = gTestBrowser.contentDocument.getElementById("test1");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 14, Plugin should be activated");
 
   var plugin = getTestPlugin();
   plugin.disabled = false;
   plugin.blocklisted = false;
-  Services.perms.removeAll();
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   prepareTest(test15, gTestRoot + "plugin_alternate_content.html");
 }
 
 // Tests that the overlay is shown instead of alternate content when
 // plugins are click to play
 function test15() {
   var plugin = gTestBrowser.contentDocument.getElementById("test");
@@ -652,17 +652,17 @@ function test18c() {
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE, "Test 18c, plugin fallback type should be PLUGIN_VULNERABLE_NO_UPDATE");
   ok(!objLoadingContent.activated, "Test 18c, Plugin should not be activated");
   var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
   ok(overlay.style.visibility != "hidden", "Test 18c, Plugin overlay should exist, not be hidden");
   var updateLink = doc.getAnonymousElementByAttribute(plugin, "class", "checkForUpdatesLink");
   ok(updateLink.style.display != "block", "Test 18c, Plugin should not have an update link");
 
-  // check that click "Always allow" works with blocklisted plugins (for now)
+  // check that click "Always allow" works with blocklisted plugins
   clickToPlayNotification.secondaryActions[0].callback();
   var condition = function() objLoadingContent.activated;
   waitForCondition(condition, test18d, "Test 18d, Waited too long for plugin to activate");
 }
 
 // continue testing "Always allow"
 function test18d() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
@@ -677,17 +677,17 @@ function test18d() {
 // continue testing "Always allow"
 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();
+  Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test"));
   setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml",
   function() {
     resetBlocklist();
     prepareTest(test19a, gTestRoot + "plugin_test.html");
   });
 }
 
 // Tests that clicking the icon of the overlay activates the plugin
@@ -1055,19 +1055,22 @@ function test24c() {
 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();
+  // this resets the vulnerable plugin permission
+  Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test"));
   setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml",
   function() {
+    // this resets the normal plugin permission
+    Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test"));
     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() {
@@ -1115,12 +1118,13 @@ function test25c() {
 
   var secondtest = gTestBrowser.contentDocument.getElementById("secondtestA");
   ok(secondtest, "Test 25c, Found second test plugin in page");
   var objLoadingContent = secondtest.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Test 25c, second test plugin should not be activated");
   var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(secondtest, "class", "mainBox");
   ok(overlay.style.visibility == "hidden", "Test 25c, second test plugin should not have visible overlay");
 
-  Services.perms.removeAll();
+  Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test"));
+  Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-second-test"));
 
   finishTest();
 }