Bug 934503 - Activated hidden plugins should not show the hidden plugin notification icon, r=jaws a=lsblakk for this entire series of plugin CtP fixes
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 07 Nov 2013 10:18:29 -0500
changeset 166434 8da8761dab7d944828ff034a6d10c3cf9ae8f96f
parent 166433 6f20a758c877eb4923c396d63d6349b9664b22f0
child 166435 f0cdd7f29d855ede1860925bd550b18fb768357f
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, lsblakk
bugs934503
milestone27.0a2
Bug 934503 - Activated hidden plugins should not show the hidden plugin notification icon, r=jaws a=lsblakk for this entire series of plugin CtP fixes
browser/base/content/browser-plugins.js
browser/base/content/test/general/browser_pluginnotification.js
--- a/browser/base/content/browser-plugins.js
+++ b/browser/base/content/browser-plugins.js
@@ -895,22 +895,29 @@ var gPluginHandler = {
 
     iconClasses.remove("plugin-blocked");
 
     let contentWindow = aBrowser.contentWindow;
     let contentDoc = aBrowser.contentDocument;
     let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                            .getInterface(Ci.nsIDOMWindowUtils);
     for (let plugin of cwu.plugins) {
-      let fallbackType = plugin.pluginFallbackType;
-      if (fallbackType != Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY) {
+      let info = this._getPluginInfo(plugin);
+      if (!actions.has(info.permissionString)) {
         continue;
       }
-      let info = this._getPluginInfo(plugin);
-      if (!actions.has(info.permissionString)) {
+      let fallbackType = info.fallbackType;
+      if (fallbackType == Ci.nsIObjectLoadingContent.PLUGIN_ACTIVE) {
+        actions.delete(info.permissionString);
+        if (actions.size == 0) {
+          break;
+        }
+        continue;
+      }
+      if (fallbackType != Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY) {
         continue;
       }
       let overlay = this.getPluginUI(plugin, "main");
       if (!overlay) {
         continue;
       }
       if (!this.isTooSmall(plugin, overlay)) {
         actions.delete(info.permissionString);
--- a/browser/base/content/test/general/browser_pluginnotification.js
+++ b/browser/base/content/test/general/browser_pluginnotification.js
@@ -839,10 +839,37 @@ function test24d() {
   });
 }
 
 function test25() {
   let notification = PopupNotifications.getNotification("click-to-play-plugins");
   ok(notification, "Test 25: There should be a plugin notification even if the plugin was immediately removed");
   ok(notification.dismissed, "Test 25: The notification should be dismissed by default");
 
-  finishTest();
+  prepareTest(() => executeSoon(test26), gTestRoot + "plugin_small.html");
 }
+
+function test26() {
+  let notification = PopupNotifications.getNotification("click-to-play-plugins");
+  ok(notification, "Test 26: There should be a plugin notification");
+
+  waitForCondition(() => gBrowser.ownerDocument.
+      getElementById("plugins-notification-icon").classList.
+      contains("plugin-hidden"),
+    () => {
+      // Don't use setTestPluginEnabledState here because we already saved the
+      // prior value
+      getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED;
+      prepareTest(test27, gTestRoot + "plugin_small.html");
+    },
+    "Test 26, expected the plugin notification icon to be highlighted");
+}
+
+function test27() {
+  let notification = PopupNotifications.getNotification("click-to-play-plugins");
+  ok(notification, "Test 27: There should be a plugin notification");
+
+  waitForCondition(() => !gBrowser.ownerDocument.
+      getElementById("plugins-notification-icon").classList.
+      contains("plugin-hidden"),
+    finishTest,
+    "Test 27, expected the plugin notification icon to not be highlighted");
+}