bug 820303 - scripted click-to-play plugins: handle deny permission r=jaws

This commit is contained in:
David Keeler 2013-01-03 11:31:04 -08:00
parent 90fdd69121
commit df5293530a
2 changed files with 37 additions and 5 deletions

View File

@ -256,8 +256,12 @@ var gPluginHandler = {
let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor) let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils); .getInterface(Ci.nsIDOMWindowUtils);
let haveVisibleCTPPlugin = cwu.plugins.some(function(plugin) { let plugins = cwu.plugins.filter(function(plugin) {
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
return gPluginHandler.canActivatePlugin(objLoadingContent);
});
let haveVisibleCTPPlugin = plugins.some(function(plugin) {
let doc = plugin.ownerDocument; let doc = plugin.ownerDocument;
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox"); let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
if (!overlay) if (!overlay)
@ -271,12 +275,11 @@ var gPluginHandler = {
let isInvisible = ((computedStyle.width == "240px" && let isInvisible = ((computedStyle.width == "240px" &&
computedStyle.height == "200px") || computedStyle.height == "200px") ||
gPluginHandler.isTooSmall(plugin, overlay)); gPluginHandler.isTooSmall(plugin, overlay));
return (!isInvisible && return !isInvisible;
gPluginHandler.canActivatePlugin(objLoadingContent));
}); });
let notification = PopupNotifications.getNotification("click-to-play-plugins", aBrowser); let notification = PopupNotifications.getNotification("click-to-play-plugins", aBrowser);
if (notification && !haveVisibleCTPPlugin && !this._notificationDisplayedOnce) { if (notification && plugins.length > 0 && !haveVisibleCTPPlugin && !this._notificationDisplayedOnce) {
notification.dismissed = false; notification.dismissed = false;
PopupNotifications._update(notification.anchorElement); PopupNotifications._update(notification.anchorElement);
this._notificationDisplayedOnce = true; this._notificationDisplayedOnce = true;

View File

@ -1,5 +1,5 @@
const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
const EXPECTED_PLUGINSCRIPTED_EVENT_COUNT = 6; const EXPECTED_PLUGINSCRIPTED_EVENT_COUNT = 7;
var gTestBrowser = null; var gTestBrowser = null;
var gNextTestList = []; var gNextTestList = [];
@ -90,6 +90,35 @@ function testNoEventFired() {
ok(notification.dismissed, "notification should not be showing (" + getCurrentTestLocation() + ")"); ok(notification.dismissed, "notification should not be showing (" + getCurrentTestLocation() + ")");
ok(!gPluginScriptedFired, "PluginScripted should not have fired (" + getCurrentTestLocation() + ")"); ok(!gPluginScriptedFired, "PluginScripted should not have fired (" + getCurrentTestLocation() + ")");
prepareTest(testDenyPermissionPart1, gHttpTestRoot + "plugin_test_noScriptNoPopup.html");
}
function testDenyPermissionPart1() {
var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "test deny permission: should have a click-to-play notification");
// Simulate clicking the "Deny Always" button.
notification.secondaryActions[1].callback();
gPluginScriptedFired = false;
prepareTest(testDenyPermissionPart2, gHttpTestRoot + "plugin_test_scriptedPopup1.html");
}
function testDenyPermissionPart2() {
var condition = function() gPluginScriptedFired;
waitForCondition(condition, testDenyPermissionPart3, "test deny permission: waited too long for PluginScripted event");
}
function testDenyPermissionPart3() {
var condition = function() gTestBrowser._pluginScriptedState == gPluginHandler.PLUGIN_SCRIPTED_STATE_DONE;
waitForCondition(condition, testDenyPermissionPart4, "test deny permission: waited too long for PluginScripted event handling");
}
function testDenyPermissionPart4() {
var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!notification, "test deny permission: should not have a click-to-play notification");
var pluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
Services.perms.remove("127.0.0.1:8888", pluginHost.getPermissionStringForType("application/x-test"));
runNextTest(); runNextTest();
} }