bug 818009 - canActivate: only click-to-play-type plugins are valid r=jaws

This commit is contained in:
David Keeler 2012-12-05 13:00:52 -08:00
Родитель c2dfb4b0e2
Коммит 233b384467
6 изменённых файлов: 63 добавлений и 1 удалений

Просмотреть файл

@ -248,7 +248,8 @@ var gPluginHandler = {
return !objLoadingContent.activated &&
pluginPermission != Ci.nsIPermissionManager.DENY_ACTION &&
objLoadingContent.pluginFallbackType !== Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW;
objLoadingContent.pluginFallbackType >= Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY &&
objLoadingContent.pluginFallbackType <= Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE;
},
activatePlugins: function PH_activatePlugins(aContentWindow) {

Просмотреть файл

@ -246,6 +246,7 @@ _BROWSER_FILES = \
plugin_clickToPlayDeny.html \
plugin_bug749455.html \
plugin_bug797677.html \
plugin_bug818009.html \
plugin_hidden_to_visible.html \
plugin_two_types.html \
alltabslistener.html \
@ -272,6 +273,7 @@ _BROWSER_FILES = \
browser_lastAccessedTab.js \
browser_bug734076.js \
browser_bug812562.js \
browser_bug818009.js \
blockPluginVulnerableUpdatable.xml \
blockPluginVulnerableNoUpdate.xml \
blockNoPlugins.xml \

Просмотреть файл

@ -0,0 +1,47 @@
var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
Components.utils.import("resource://gre/modules/Services.jsm");
function test() {
waitForExplicitFinish();
registerCleanupFunction(function() {
Services.prefs.clearUserPref("plugins.click_to_play");
gTestBrowser.removeEventListener("load", pageLoad, true);
});
Services.prefs.setBoolPref("plugins.click_to_play", true);
gBrowser.selectedTab = gBrowser.addTab();
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("load", pageLoad, true);
gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug818009.html";
}
function pageLoad() {
// The plugin events are async dispatched and can come after the load event
// This just allows the events to fire before we then go on to test the states
executeSoon(actualTest);
}
function actualTest() {
var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "should have a click-to-play notification");
is(notification.options.centerActions.length, 1, "should have only one type of plugin in the notification");
is(notification.options.centerActions[0].message, "Test", "the one type of plugin should be the 'Test' plugin");
var doc = gTestBrowser.contentDocument;
var inner = doc.getElementById("inner");
ok(inner, "should have 'inner' plugin");
var innerObjLC = inner.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!innerObjLC.activated, "inner plugin shouldn't be activated");
is(innerObjLC.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "inner plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
var outer = doc.getElementById("outer");
ok(outer, "should have 'outer' plugin");
var outerObjLC = outer.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!outerObjLC.activated, "outer plugin shouldn't be activated");
is(outerObjLC.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_ALTERNATE, "outer plugin fallback type should be PLUGIN_ALTERNATE");
gBrowser.removeCurrentTab();
window.focus();
finish();
}

Просмотреть файл

@ -0,0 +1,8 @@
<!DOCTYPE html>
<head><meta charset="utf8"/></head>
<body>
<object id="outer" width="200" height="200">
<embed id="inner" width="200" height="200" type="application/x-test"/>
</object>
</body>
</html>

Просмотреть файл

@ -51,6 +51,8 @@ interface nsIObjectLoadingContent : nsISupports
const unsigned long PLUGIN_USER_DISABLED = 7;
/// ** All values >= PLUGIN_CLICK_TO_PLAY are plugin placeholder types that
/// would be replaced by a real plugin if activated (playPlugin())
/// ** Furthermore, values >= PLUGIN_CLICK_TO_PLAY and
/// <= PLUGIN_VULNERABLE_NO_UPDATE are click-to-play types.
// The plugin is disabled until the user clicks on it
const unsigned long PLUGIN_CLICK_TO_PLAY = 8;
// The plugin is vulnerable (update available)

Просмотреть файл

@ -79,6 +79,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent
eFallbackUserDisabled = nsIObjectLoadingContent::PLUGIN_USER_DISABLED,
/// ** All values >= eFallbackClickToPlay are plugin placeholder types
/// that would be replaced by a real plugin if activated (PlayPlugin())
/// ** Furthermore, values >= eFallbackClickToPlay and
/// <= eFallbackVulnerableNoUpdate are click-to-play types.
// The plugin is disabled until the user clicks on it
eFallbackClickToPlay = nsIObjectLoadingContent::PLUGIN_CLICK_TO_PLAY,
// The plugin is vulnerable (update available)