Bug 711618 - Automated tests for plugin activation permissions. r=felipe a=blassey

This commit is contained in:
Jared Wein 2012-04-18 11:41:26 -07:00
parent 523a51a655
commit 2df5f4abe9
5 changed files with 114 additions and 10 deletions

View File

@ -251,6 +251,8 @@ _BROWSER_FILES = \
plugin_test3.html \
plugin_both.html \
plugin_both2.html \
plugin_clickToPlayAllow.html \
plugin_clickToPlayDeny.html \
alltabslistener.html \
zoom_test.html \
dummy_page.html \

View File

@ -230,12 +230,12 @@ function test9a() {
var rect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect();
ok(rect.width == 200, "Test 9a, Plugin with id=" + plugin.id + " overlay rect should have 200px width before being clicked");
ok(rect.height == 200, "Test 9a, Plugin with id=" + plugin.id + " overlay rect should have 200px height before being clicked");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 9a, Plugin with id=" + plugin.id + " should not be activated");
});
EventUtils.synthesizeMouse(plugin1, 100, 100, { });
setTimeout(test9b, 0);
setTimeout(test9b, 1000);
}
// Tests that activating one click-to-play plugin will activate the other plugins (part 2/2)
@ -254,7 +254,7 @@ function test9b() {
var pluginRect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect();
ok(pluginRect.width == 0, "Test 9b, Plugin with id=" + plugin.id + " should have click-to-play overlay with zero width");
ok(pluginRect.height == 0, "Test 9b, Plugin with id=" + plugin.id + " should have click-to-play overlay with zero height");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 9b, Plugin with id=" + plugin.id + " should be activated");
});
@ -270,8 +270,8 @@ function test10a() {
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "Test 10a, Should have a click-to-play notification");
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 10c, Plugin should not be activated");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 10a, Plugin should not be activated");
popupNotification.mainAction.callback();
setTimeout(test10b, 0);
@ -280,8 +280,8 @@ function test10a() {
// Tests that activating a hidden click-to-play plugin through the notification works (part 2/2)
function test10b() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 10c, Plugin should be activated");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 10b, Plugin should be activated");
prepareTest(test11a, gTestRoot + "plugin_test3.html");
}
@ -314,6 +314,89 @@ function test11c() {
is(gClickToPlayPluginActualEvents, gClickToPlayPluginExpectedEvents,
"There should be a PluginClickToPlay event for each plugin that was " +
"blocked due to the plugins.click_to_play pref");
finishTest();
prepareTest(test12a, gTestRoot + "plugin_clickToPlayAllow.html");
});
}
// Tests that the "Allow Always" permission works for click-to-play plugins (part 1/3)
function test12a() {
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "Test 12a, Should have a click-to-play notification");
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 12a, Plugin should not be activated");
popupNotification.secondaryActions[0].callback();
setTimeout(test12b, 0);
}
// Tests that the "Always" permission works for click-to-play plugins (part 2/3)
function test12b() {
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "Test 12b, Should not have a click-to-play notification");
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 12b, Plugin should be activated");
prepareTest(test12c, gTestRoot + "plugin_clickToPlayAllow.html");
}
// Tests that the "Always" permission works for click-to-play plugins (part 3/3)
function test12c() {
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "Test 12c, Should not have a click-to-play notification");
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 12c, Plugin should be activated");
Services.perms.removeAll();
gNextTest = test13a;
gTestBrowser.reload();
}
// Tests that the "Deny Always" permission works for click-to-play plugins (part 1/3)
function test13a() {
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "Test 13a, Should have a click-to-play notification");
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 13a, Plugin should not be activated");
popupNotification.secondaryActions[1].callback();
setTimeout(test13b, 0);
}
// 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");
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);
ok(!popupNotification, "Test 13c, Should not have a click-to-play notification");
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 13c, Plugin should not be activated");
Services.perms.removeAll();
Services.prefs.setBoolPref("plugins.click_to_play", false);
prepareTest(test14, gTestRoot + "plugin_test2.html");
}
// Tests that the plugin's "activated" property is true for working plugins with click-to-play disabled.
function test14() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 14, Plugin should be activated");
finishTest();
}

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

View File

@ -21,7 +21,8 @@ const TEST_PERMS = {
"cookie": PERM_ALLOW,
"geo": PERM_UNKNOWN,
"indexedDB": PERM_UNKNOWN,
"popup": PERM_DENY
"popup": PERM_DENY,
"plugins" : PERM_ALLOW
};
const NO_GLOBAL_ALLOW = [
@ -30,7 +31,7 @@ const NO_GLOBAL_ALLOW = [
];
// number of managed permissions in the interface
const TEST_PERMS_COUNT = 5;
const TEST_PERMS_COUNT = 6;
function test() {
waitForExplicitFinish();