bug 820497 - update popup notification for click-to-play more often r=jaws

This commit is contained in:
David Keeler 2012-12-17 16:12:14 -08:00
parent 4aca71290f
commit b884265122
5 changed files with 73 additions and 6 deletions

View File

@ -336,7 +336,6 @@ var gPluginHandler = {
let browser = gBrowser.getBrowserForDocument(aContentWindow.document); let browser = gBrowser.getBrowserForDocument(aContentWindow.document);
let notification = PopupNotifications.getNotification("click-to-play-plugins", browser); let notification = PopupNotifications.getNotification("click-to-play-plugins", browser);
if (notification) { if (notification) {
browser._clickToPlayDoorhangerShown = false;
notification.remove(); notification.remove();
} }
if (pluginNeedsActivation) { if (pluginNeedsActivation) {
@ -452,8 +451,7 @@ var gPluginHandler = {
}, true); }, true);
} }
if (!browser._clickToPlayDoorhangerShown) gPluginHandler._showClickToPlayNotification(browser);
gPluginHandler._showClickToPlayNotification(browser);
}, },
_handlePlayPreviewEvent: function PH_handlePlayPreviewEvent(aPlugin) { _handlePlayPreviewEvent: function PH_handlePlayPreviewEvent(aPlugin) {
@ -601,9 +599,7 @@ var gPluginHandler = {
}, },
_showClickToPlayNotification: function PH_showClickToPlayNotification(aBrowser) { _showClickToPlayNotification: function PH_showClickToPlayNotification(aBrowser) {
aBrowser._clickToPlayDoorhangerShown = true;
let contentWindow = aBrowser.contentWindow; let contentWindow = aBrowser.contentWindow;
let messageString = gNavigatorBundle.getString("activatePluginsMessage.message"); let messageString = gNavigatorBundle.getString("activatePluginsMessage.message");
let mainAction = { let mainAction = {
label: gNavigatorBundle.getString("activateAllPluginsMessage.label"), label: gNavigatorBundle.getString("activateAllPluginsMessage.label"),

View File

@ -4518,7 +4518,6 @@ var TabsProgressListener = {
// or history.push/pop/replaceState. // or history.push/pop/replaceState.
if (aRequest) { if (aRequest) {
// Initialize the click-to-play state. // Initialize the click-to-play state.
aBrowser._clickToPlayDoorhangerShown = false;
aBrowser._clickToPlayPluginsActivated = false; aBrowser._clickToPlayPluginsActivated = false;
aBrowser._pluginScriptedState = gPluginHandler.PLUGIN_SCRIPTED_STATE_NONE; aBrowser._pluginScriptedState = gPluginHandler.PLUGIN_SCRIPTED_STATE_NONE;
} }

View File

@ -255,6 +255,7 @@ _BROWSER_FILES = \
plugin_bug749455.html \ plugin_bug749455.html \
plugin_bug797677.html \ plugin_bug797677.html \
plugin_bug818009.html \ plugin_bug818009.html \
plugin_bug820497.html \
plugin_hidden_to_visible.html \ plugin_hidden_to_visible.html \
plugin_two_types.html \ plugin_two_types.html \
alltabslistener.html \ alltabslistener.html \
@ -283,6 +284,7 @@ _BROWSER_FILES = \
browser_bug812562.js \ browser_bug812562.js \
browser_bug818009.js \ browser_bug818009.js \
browser_bug818118.js \ browser_bug818118.js \
browser_bug820497.js \
blockPluginVulnerableUpdatable.xml \ blockPluginVulnerableUpdatable.xml \
blockPluginVulnerableNoUpdate.xml \ blockPluginVulnerableNoUpdate.xml \
blockNoPlugins.xml \ blockNoPlugins.xml \

View File

@ -0,0 +1,53 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var gTestBrowser = null;
var gNumPluginBindingsAttached = 0;
Components.utils.import("resource://gre/modules/Services.jsm");
function test() {
waitForExplicitFinish();
registerCleanupFunction(function() {
Services.prefs.clearUserPref("plugins.click_to_play");
gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
gBrowser.removeCurrentTab();
window.focus();
});
Services.prefs.setBoolPref("plugins.click_to_play", true);
gBrowser.selectedTab = gBrowser.addTab();
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug820497.html";
}
function pluginBindingAttached() {
gNumPluginBindingsAttached++;
if (gNumPluginBindingsAttached == 1) {
var doc = gTestBrowser.contentDocument;
var testplugin = doc.getElementById("test");
ok(testplugin, "should have test plugin");
var secondtestplugin = doc.getElementById("secondtest");
ok(!secondtestplugin, "should not yet have second test plugin");
var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "should have popup notification");
is(notification.options.centerActions.length, 1, "should be 1 type of plugin in the popup notification");
} else if (gNumPluginBindingsAttached == 2) {
var doc = gTestBrowser.contentDocument;
var testplugin = doc.getElementById("test");
ok(testplugin, "should have test plugin");
var secondtestplugin = doc.getElementById("secondtest");
ok(secondtestplugin, "should have second test plugin");
var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "should have popup notification");
is(notification.options.centerActions.length, 2, "should be 2 types of plugin in the popup notification");
finish();
} else {
ok(false, "if we've gotten here, something is quite wrong");
}
}

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/></head>
<body onload="addSecondPlugin()">
<object id="test" type="application/x-test" width=200 height=200></object>
<script>
function addSecondPlugin() {
var object = document.createElement("object");
object.type = "application/x-second-test";
object.width = 200;
object.height = 200;
object.id = "secondtest";
document.body.appendChild(object);
}
</script>
</body>
</html>