Bug 914609 Consistently use plugin placeholder anonymous element anonids r=jaws

--HG--
extra : rebase_source : 97d098dfb89a05bb23fbd0eb2bf925fb46fbf642
This commit is contained in:
Neil Rashbrook 2013-09-11 08:31:36 +01:00
parent 033f3f9ca3
commit 4d616c626b
2 changed files with 24 additions and 25 deletions

View File

@ -12,9 +12,9 @@ var gPluginHandler = {
PREF_SESSION_PERSIST_MINUTES: "plugin.sessionPermissionNow.intervalInMinutes",
PREF_PERSISTENT_DAYS: "plugin.persistentPermissionAlways.intervalInDays",
getPluginUI: function (plugin, className) {
getPluginUI: function (plugin, anonid) {
return plugin.ownerDocument.
getAnonymousElementByAttribute(plugin, "class", className);
getAnonymousElementByAttribute(plugin, "anonid", anonid);
},
#ifdef MOZ_CRASHREPORTER
@ -236,7 +236,7 @@ var gPluginHandler = {
// The plugin binding fires this event when it is created.
// As an untrusted event, ensure that this object actually has a binding
// and make sure we don't handle it twice
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
let overlay = this.getPluginUI(plugin, "main");
if (!overlay || overlay._bindingHandled) {
return;
}
@ -264,12 +264,12 @@ var gPluginHandler = {
// plugin. Object tags can, and often do, deal with that themselves,
// so don't stomp on the page developers toes.
if (installable && !(plugin instanceof HTMLObjectElement)) {
let installStatus = doc.getAnonymousElementByAttribute(plugin, "class", "installStatus");
let installStatus = this.getPluginUI(plugin, "installStatus");
installStatus.setAttribute("installable", "true");
let iconStatus = doc.getAnonymousElementByAttribute(plugin, "class", "icon");
let iconStatus = this.getPluginUI(plugin, "icon");
iconStatus.setAttribute("installable", "true");
let installLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "installPluginLink");
let installLink = this.getPluginUI(plugin, "installPluginLink");
this.addLinkClickCallback(installLink, "installSinglePlugin", plugin);
}
break;
@ -280,22 +280,22 @@ var gPluginHandler = {
break;
case "PluginVulnerableUpdatable":
let updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink");
let updateLink = this.getPluginUI(plugin, "checkForUpdatesLink");
this.addLinkClickCallback(updateLink, "openPluginUpdatePage");
/* FALLTHRU */
case "PluginVulnerableNoUpdate":
case "PluginClickToPlay":
this._handleClickToPlayEvent(plugin);
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
let overlay = this.getPluginUI(plugin, "main");
let pluginName = this._getPluginInfo(plugin).pluginName;
let messageString = gNavigatorBundle.getFormattedString("PluginClickToActivate", [pluginName]);
let overlayText = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgClickToPlay");
let overlayText = this.getPluginUI(plugin, "clickToPlay");
overlayText.textContent = messageString;
if (eventType == "PluginVulnerableUpdatable" ||
eventType == "PluginVulnerableNoUpdate") {
let vulnerabilityString = gNavigatorBundle.getString(eventType);
let vulnerabilityText = doc.getAnonymousElementByAttribute(plugin, "anonid", "vulnerabilityStatus");
let vulnerabilityText = this.getPluginUI(plugin, "vulnerabilityStatus");
vulnerabilityText.textContent = vulnerabilityString;
}
shouldShowNotification = true;
@ -306,7 +306,7 @@ var gPluginHandler = {
break;
case "PluginDisabled":
let manageLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "managePluginsLink");
let manageLink = this.getPluginUI(plugin, "managePluginsLink");
this.addLinkClickCallback(manageLink, "managePlugins");
shouldShowNotification = true;
break;
@ -319,7 +319,7 @@ var gPluginHandler = {
// Hide the in-content UI if it's too big. The crashed plugin handler already did this.
if (eventType != "PluginCrashed" && eventType != "PluginRemoved") {
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
let overlay = this.getPluginUI(plugin, "main");
if (overlay != null && this.isTooSmall(plugin, overlay))
overlay.style.visibility = "hidden";
}
@ -364,7 +364,7 @@ var gPluginHandler = {
},
hideClickToPlayOverlay: function(aPlugin) {
let overlay = aPlugin.ownerDocument.getAnonymousElementByAttribute(aPlugin, "class", "mainBox");
let overlay = this.getPluginUI(aPlugin, "main");
if (overlay)
overlay.style.visibility = "hidden";
},
@ -514,7 +514,7 @@ var gPluginHandler = {
let principal = doc.defaultView.top.document.nodePrincipal;
let pluginPermission = Services.perms.testPermissionFromPrincipal(principal, permissionString);
let overlay = doc.getAnonymousElementByAttribute(aPlugin, "class", "mainBox");
let overlay = this.getPluginUI(aPlugin, "main");
if (pluginPermission == Ci.nsIPermissionManager.DENY_ACTION) {
if (overlay)
@ -524,7 +524,7 @@ var gPluginHandler = {
if (overlay) {
overlay.addEventListener("click", gPluginHandler._overlayClickListener, true);
let closeIcon = doc.getAnonymousElementByAttribute(aPlugin, "anonid", "closeIcon");
let closeIcon = this.getPluginUI(aPlugin, "closeIcon");
closeIcon.addEventListener("click", function(aEvent) {
if (aEvent.button == 0 && aEvent.isTrusted)
gPluginHandler.hideClickToPlayOverlay(aPlugin);
@ -567,7 +567,7 @@ var gPluginHandler = {
let pluginInfo = this._getPluginInfo(aPlugin);
let playPreviewInfo = pluginHost.getPlayPreviewInfo(pluginInfo.mimetype);
let previewContent = doc.getAnonymousElementByAttribute(aPlugin, "class", "previewPluginContent");
let previewContent = this.getPluginUI(aPlugin, "previewPluginContent");
let iframe = previewContent.getElementsByClassName("previewPluginContentFrame")[0];
if (!iframe) {
// lazy initialization of the iframe
@ -607,10 +607,9 @@ var gPluginHandler = {
let contentWindow = browser.contentWindow;
let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let doc = contentWindow.document;
let plugins = cwu.plugins;
for (let plugin of plugins) {
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
let overlay = this.getPluginUI(plugin, "main");
if (overlay)
overlay.removeEventListener("click", gPluginHandler._overlayClickListener, true);
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
@ -814,7 +813,7 @@ var gPluginHandler = {
break;
}
if (fallbackType == plugin.PLUGIN_CLICK_TO_PLAY) {
let overlay = contentDoc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
let overlay = this.getPluginUI(plugin, "main");
if (!overlay || overlay.style.visibility == 'hidden') {
icon = 'alert-plugins-notification-icon';
}
@ -888,9 +887,9 @@ var gPluginHandler = {
// Force a layout flush so the binding is attached.
plugin.clientTop;
let overlay = this.getPluginUI(plugin, "main");
let statusDiv = this.getPluginUI(plugin, "submitStatus");
let doc = plugin.ownerDocument;
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
let statusDiv = doc.getAnonymousElementByAttribute(plugin, "class", "submitStatus");
#ifdef MOZ_CRASHREPORTER
let status;
@ -923,7 +922,7 @@ var gPluginHandler = {
statusDiv.setAttribute("status", status);
let helpIcon = doc.getAnonymousElementByAttribute(plugin, "class", "helpIcon");
let helpIcon = this.getPluginUI(plugin, "helpIcon");
this.addLinkClickCallback(helpIcon, "openHelpPage");
// If we're showing the link to manually trigger report submission, we'll
@ -959,12 +958,12 @@ var gPluginHandler = {
}
#endif
let crashText = doc.getAnonymousElementByAttribute(plugin, "class", "msgCrashedText");
let crashText = this.getPluginUI(plugin, "crashedText");
crashText.textContent = messageString;
let browser = gBrowser.getBrowserForDocument(doc.defaultView.top.document);
let link = doc.getAnonymousElementByAttribute(plugin, "class", "reloadLink");
let link = this.getPluginUI(plugin, "reloadLink");
this.addLinkClickCallback(link, "reloadPage", browser);
let notificationBox = gBrowser.getNotificationBox(browser);

View File

@ -89,7 +89,7 @@ function onCrash() {
let plugin = gBrowser.contentDocument.getElementById("plugin");
let elt = gPluginHandler.getPluginUI.bind(gPluginHandler, plugin);
let style =
gBrowser.contentWindow.getComputedStyle(elt("msg msgPleaseSubmit"));
gBrowser.contentWindow.getComputedStyle(elt("pleaseSubmit"));
is(style.display,
currentRun.shouldSubmissionUIBeVisible ? "block" : "none",
"Submission UI visibility should be correct");