Bug 807664 Port |Bug 752461 - First time after choosing to "Never activate plugins for this site" the video is still playing| r=mcsmurf.
authorPhilip Chee <philip.chee@gmail.com>
Tue, 29 Jan 2013 22:47:42 +0800
changeset 14762 d974df0945d35b38d16fa570e3b22df1c383989e
parent 14761 eee5b211537ba2fb6fc62898786eb9bdac943838
child 14763 4f09ff153f86167bfcc980fc1a9a32c28c20ca40
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcsmurf
bugs807664, 752461
Bug 807664 Port |Bug 752461 - First time after choosing to "Never activate plugins for this site" the video is still playing| r=mcsmurf.
suite/browser/test/browser/browser_pluginnotification.js
suite/common/bindings/notification.xml
--- a/suite/browser/test/browser/browser_pluginnotification.js
+++ b/suite/browser/test/browser/browser_pluginnotification.js
@@ -71,17 +71,16 @@ function test() {
 function finishTest() {
   gTestBrowser.removeEventListener("load", pageLoad, true);
   gTestBrowser.removeEventListener("PluginBindingAttached", handleBindingAttached, true);
   gBrowser.removeCurrentTab();
   window.focus();
   finish();
 }
 
-
 function handleBindingAttached(evt) {
   if (evt.target instanceof Ci.nsIObjectLoadingContent &&
       evt.target.pluginFallbackType == Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY)
     gClickToPlayPluginActualEvents++;
 }
 
 function pageLoad() {
   // The plugin events are async dispatched and can come after the load event
@@ -431,18 +430,17 @@ function test13a() {
 // Tests that the "Deny Always" permission works for click-to-play plugins (part 2/3)
 function test13b() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!popupNotification, "Test 13b, Should not have a click-to-play notification");
   var plugin = gTestBrowser.contentDocument.getElementById("test");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Test 13b, Plugin should not be activated");
   var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(plugin, "class", "mainBox");
-  // See Bug 807644 on this
-  todo(overlay.style.visibility == "hidden", "Test 13b, Plugin should not have visible overlay");
+  ok(overlay.style.visibility == "hidden", "Test 13b, Plugin should not have visible overlay");
 
   gNextTest = test13c;
   gTestBrowser.reload();
 }
 
 // Tests that the "Deny Always" permission works for click-to-play plugins (part 3/3)
 function test13c() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
--- a/suite/common/bindings/notification.xml
+++ b/suite/common/bindings/notification.xml
@@ -575,25 +575,25 @@
               let objLoadingContent = plugin.QueryInterface(Components.interfaces.nsIObjectLoadingContent);
               if (this.canActivatePlugin(objLoadingContent))
                 objLoadingContent.playPlugin();
             }
             this.removePluginClickToPlayPrompt();
           ]]>
         </body>
       </method>
-      
+
       <method name="activateSinglePlugin">
         <parameter name="aPlugin"/>
         <body>
           <![CDATA[
             var objLoadingContent = aPlugin.QueryInterface(Components.interfaces.nsIObjectLoadingContent);
             if (this.canActivatePlugin(objLoadingContent))
               objLoadingContent.playPlugin();
-        
+
             var haveUnplayedPlugins = this.contentWindowUtils.plugins.some(function(plugin) {
               var hupObjLoadingContent = plugin.QueryInterface(Components.interfaces.nsIObjectLoadingContent);
               return plugin != aPlugin && this.canActivatePlugin(hupObjLoadingContent);
             }, this);
             if (!haveUnplayedPlugins) {
               this.removePluginClickToPlayPrompt();
               this.clickToPlayPromptShown = false;
             }
@@ -2273,28 +2273,42 @@
               accessKey: this._stringBundle.GetStringFromName("activatepluginsMessage.never.accesskey"),
               callback: (function () {
                 pm.add(this.activeBrowser.currentURI, "plugins",
                        nsIPermissionManager.DENY_ACTION);
                 var notification = PopupNotifications.getNotification("click-to-play-plugins",
                                                                       this.activeBrowser);
                 if (notification)
                   notification.remove();
+                this.removeClickToPlayOverlays();
               }).bind(this)
             }];
             var options = {
               dismissed: true
             };
             PopupNotifications.show(this.activeBrowser, "click-to-play-plugins",
                                     messageString, "plugins-notification-icon",
                                     mainAction, secondaryActions, options);
            ]]>
         </body>
       </method>
 
+      <method name="removeClickToPlayOverlays">
+        <body>
+          <![CDATA[
+            var doc = this.activeBrowser.contentWindow.document;
+            var plugins = this.contentWindowUtils.plugins;
+            for (let plugin of plugins) {
+              let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
+              overlay.style.visibility = "hidden";
+            }
+           ]]>
+        </body>
+      </method>
+
       <method name="showGeolocationPrompt">
         <parameter name="file"/>
         <parameter name="site"/>
         <parameter name="allowCallback"/>
         <parameter name="cancelCallback"/>
         <body>
           <![CDATA[
             var type = "geolocation";