bug 832481 - require doorhanger to activate vulnerable click-to-play plugins r=jaws

This commit is contained in:
David Keeler 2013-03-08 15:51:34 -08:00
parent 69598ffadf
commit a1a41aefd4
2 changed files with 35 additions and 3 deletions

View File

@ -470,7 +470,13 @@ var gPluginHandler = {
if (!(aEvent.originalTarget instanceof HTMLAnchorElement) &&
(aEvent.originalTarget.getAttribute('anonid') != 'closeIcon') &&
aEvent.button == 0 && aEvent.isTrusted) {
gPluginHandler.activateSinglePlugin(aEvent.target.ownerDocument.defaultView.top, aPlugin);
if (objLoadingContent.pluginFallbackType ==
Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE ||
objLoadingContent.pluginFallbackType ==
Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE)
gPluginHandler._showClickToPlayNotification(browser, true);
else
gPluginHandler.activateSinglePlugin(aEvent.target.ownerDocument.defaultView.top, aPlugin);
aEvent.stopPropagation();
aEvent.preventDefault();
}
@ -648,7 +654,7 @@ var gPluginHandler = {
}
},
_showClickToPlayNotification: function PH_showClickToPlayNotification(aBrowser) {
_showClickToPlayNotification: function PH_showClickToPlayNotification(aBrowser, aForceOpenNotification) {
let contentWindow = aBrowser.contentWindow;
let messageString = gNavigatorBundle.getString("activatePluginsMessage.message");
let mainAction = {
@ -689,7 +695,7 @@ var gPluginHandler = {
let notification = PopupNotifications.getNotification("click-to-play-plugins", aBrowser);
let dismissed = notification ? notification.dismissed : true;
// Always show the doorhanger if the anchor is not available.
if (!isElementVisible(gURLBar))
if (!isElementVisible(gURLBar) || aForceOpenNotification)
dismissed = false;
let options = { dismissed: dismissed, centerActions: centerActions };
let icon = haveVulnerablePlugin ? "blocked-plugins-notification-icon" : "plugins-notification-icon"

View File

@ -683,6 +683,32 @@ function test18e() {
ok(objLoadingContent.activated, "Test 18e, Plugin should be activated");
Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test"));
prepareTest(test18f, gHttpTestRoot + "plugin_test.html");
}
// clicking the in-content overlay of a vulnerable plugin should bring
// up the notification and not directly activate the plugin
function test18f() {
var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 18f, Should have a click-to-play notification");
ok(notification.dismissed, "Test 18f, notification should start dismissed");
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 18f, Plugin should not be activated");
notification.options.eventCallback = function() { executeSoon(test18g); };
EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow);
}
function test18g() {
var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 18g, Should have a click-to-play notification");
ok(!notification.dismissed, "Test 18g, notification should be open");
notification.options.eventCallback = null;
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 18g, Plugin should not be activated");
setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml",
function() {
resetBlocklist();