Bug 922107 - Add test for pref to hide the "missing plugin" notifications. r=jaws
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Mon, 24 Feb 2014 12:06:38 +0100
changeset 170689 b43455151bcab60d9ea9e9bbc5ecc1751bff6902
parent 170688 45dda38512245134d260fe799a59aeeb668749c0
child 170690 c78dc7394594cdee1736f3c9c1949eb3a538f2bc
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjaws
bugs922107
milestone30.0a1
Bug 922107 - Add test for pref to hide the "missing plugin" notifications. r=jaws
browser/base/content/test/general/browser_pluginnotification.js
--- a/browser/base/content/test/general/browser_pluginnotification.js
+++ b/browser/base/content/test/general/browser_pluginnotification.js
@@ -55,27 +55,28 @@ TabOpenListener.prototype = {
 };
 
 function test() {
   waitForExplicitFinish();
   requestLongerTimeout(2);
   registerCleanupFunction(function() {
     clearAllPluginPermissions();
     Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
+    Services.prefs.clearUserPref("plugins.hideMissingPluginsNotification");
   });
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
 
   var newTab = gBrowser.addTab();
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
   gTestBrowser.addEventListener("load", pageLoad, true);
-  prepareTest(runAfterPluginBindingAttached(test1), gTestRoot + "plugin_unknown.html");
+  prepareTest(runAfterPluginBindingAttached(test1a), gTestRoot + "plugin_unknown.html");
 }
 
 function finishTest() {
   clearAllPluginPermissions();
   gTestBrowser.removeEventListener("load", pageLoad, true);
   gBrowser.removeCurrentTab();
   window.focus();
   finish();
@@ -104,29 +105,39 @@ function runAfterPluginBindingAttached(f
       elems = doc.getElementsByTagName('object');
     }
     elems[0].clientTop;
     executeSoon(func);
   };
 }
 
 // Tests a page with an unknown plugin in it.
-function test1() {
-  ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 1, Should have displayed the missing plugin notification");
-  ok(gTestBrowser.missingPlugins, "Test 1, Should be a missing plugin list");
-  ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 1, Should know about application/x-unknown");
-  ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 1, Should not know about application/x-test");
+function test1a() {
+  ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 1a, Should have displayed the missing plugin notification");
+  ok(gTestBrowser.missingPlugins, "Test 1a, Should be a missing plugin list");
+  ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 1a, Should know about application/x-unknown");
+  ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 1a, Should not know about application/x-test");
 
   var pluginNode = gTestBrowser.contentDocument.getElementById("unknown");
-  ok(pluginNode, "Test 1, Found plugin in page");
+  ok(pluginNode, "Test 1a, Found plugin in page");
   var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent);
-  is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED, "Test 1, plugin fallback type should be PLUGIN_UNSUPPORTED");
+  is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED, "Test 1a, plugin fallback type should be PLUGIN_UNSUPPORTED");
+
+  Services.prefs.setBoolPref("plugins.hideMissingPluginsNotification", true);
+  prepareTest(runAfterPluginBindingAttached(test1b), gTestRoot + "plugin_unknown.html");
+}
+
+
+function test1b() {
+  ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 1b, Should not have displayed the missing plugin notification");
+  ok(!gTestBrowser.missingPlugins, "Test 1b, Should not be a missing plugin list");
+  Services.prefs.clearUserPref("plugins.hideMissingPluginsNotification");
 
   var plugin = getTestPlugin();
-  ok(plugin, "Should have a test plugin");
+  ok(plugin, "Test 1b, Should have a test plugin");
   plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
   prepareTest(runAfterPluginBindingAttached(test2), gTestRoot + "plugin_test.html");
 }
 
 // Tests a page with a working plugin in it.
 function test2() {
   ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 2, Should not have displayed the missing plugin notification");
   ok(!gTestBrowser.missingPlugins, "Test 2, Should not be a missing plugin list");