Partial fix for Bug 841996 - Permanent orange: TEST-UNEXPECTED-FAIL | test-plugin-crashing.js | test-plugin-crashing.js::test_crashed_plugin_notification_bar / test_crashed_plugin_notification_inline - port the changes from core bug 648675 to fix one of the failing tests. r=mconley, a=mbanner.
authorMark Banner <bugzilla@standard8.plus.com>
Wed, 27 Mar 2013 16:37:15 -0400
changeset 14957 b4ef7d7d286c95af85e0f25b293fa3d5b9068961
parent 14956 8077003d5f7fd0c1fe98ea83b0ea90a8a05dcf45
child 14958 2b518e617ffd82321d9cb6fd525ccb5f978aa3d1
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, mbanner
bugs841996, 648675
Partial fix for Bug 841996 - Permanent orange: TEST-UNEXPECTED-FAIL | test-plugin-crashing.js | test-plugin-crashing.js::test_crashed_plugin_notification_bar / test_crashed_plugin_notification_inline - port the changes from core bug 648675 to fix one of the failing tests. r=mconley, a=mbanner.
mail/base/content/plugins.js
--- a/mail/base/content/plugins.js
+++ b/mail/base/content/plugins.js
@@ -73,16 +73,20 @@ var gPluginHandler = {
 
   removeEventListeners: function ph_removeEventListeners(browser) {
     browser.removeEventListener("PluginBindingAttached", gPluginHandler);
     browser.removeEventListener("PluginCrashed", gPluginHandler);
     browser.removeEventListener("PluginOutdated", gPluginHandler);
     browser.removeEventListener("NewPluginInstalled", gPluginHandler);
   },
 
+  getPluginUI: function (plugin, className) {
+    return plugin.ownerDocument.getAnonymousElementByAttribute(plugin, "class", className);
+  },
+
   get CrashSubmit() {
     delete this.CrashSubmit;
     Components.utils.import("resource://gre/modules/CrashSubmit.jsm", this);
     return this.CrashSubmit;
   },
 
   // Map the plugin's name to a filtered version more suitable for user UI.
   makeNicePluginName : function ph_makeNicePluginName(aName, aFilename) {
@@ -264,24 +268,29 @@ var gPluginHandler = {
   },
 
   // Callback for user clicking on a disabled plugin
   managePlugins: function ph_managePlugins(aEvent) {
     openAddonsMgr("addons://list/plugin");
   },
 
   // Callback for user clicking "submit a report" link
-  submitReport : function ph_submitReport(pluginDumpID, browserDumpID) {
-    // The crash reporter wants a DOM element it can append an IFRAME to,
-    // which it uses to submit a form. Let's just give it curBrowser.
-
+  submitReport : function ph_submitReport(pluginDumpID, browserDumpID, plugin) {
+    let keyVals = {};
+    if (plugin) {
+      let userComment = this.getPluginUI(plugin, "submitComment").value.trim();
+      if (userComment)
+        keyVals.PluginUserComment = userComment;
+      if (this.getPluginUI(plugin, "submitURLOptIn").checked)
+        keyVals.PluginContentURL = plugin.ownerDocument.URL;
+    }
     var curBrowser = document.getElementById('tabmail').getBrowserForSelectedTab();
-    this.CrashSubmit.submit(pluginDumpID, curBrowser, null, null);
+    this.CrashSubmit.submit(pluginDumpID, { extraExtraKeyVals: keyVals });
     if (browserDumpID)
-      this.CrashSubmit.submit(browserDumpID, curBrowser, null, null);
+      this.CrashSubmit.submit(browserDumpID);
   },
 
   // Callback for user clicking a "reload page" link
   reloadPage: function ph_reloadPage(browser) {
     browser.reload();
   },
 
   // Callback for user clicking the help icon
@@ -539,32 +548,36 @@ var gPluginHandler = {
       status = "submitted";
     }
     else if (!submitReports && !doPrompt) {
       status = "noSubmit";
     }
     else { // doPrompt
       status = "please";
       // XXX can we make the link target actually be blank?
-      let pleaseLink = doc.getAnonymousElementByAttribute(
-                            plugin, "class", "pleaseSubmitLink");
-      this.addLinkClickCallback(pleaseLink, "submitReport",
-                                pluginDumpID, browserDumpID);
+      this.getPluginUI(plugin, "submitButton").addEventListener("click",
+        function (event) {
+	  if (event.button != 0 || !event.isTrusted)
+            return;
+          this.submitReport(pluginDumpID, browserDumpID, plugin);
+          pref.setBoolPref("", optInCB.checked);
+	}.bind(this));
+      let optInCB = this.getPluginUI(plugin, "submitURLOptIn");
+      let pref = Services.prefs.getBranch("dom.ipc.plugins.reportCrashURL");
+      optInCB.checked = pref.getBoolPref("");
     }
 
     // If we don't have a minidumpID, we can't (or didn't) submit anything.
     // This can happen if the plugin is killed from the task manager.
     if (!pluginDumpID) {
       status = "noReport";
     }
 
     statusDiv.setAttribute("status", status);
 
-    let bottomLinks = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgBottomLinks");
-    bottomLinks.style.display = "block";
     let helpIcon = doc.getAnonymousElementByAttribute(plugin, "class", "helpIcon");
     this.addLinkClickCallback(helpIcon, "openPluginCrashHelpPage");
 
     // If we're showing the link to manually trigger report submission, we'll
     // want to be able to update all the instances of the UI for this crash to
     // show an updated message when a report is submitted.
     if (doPrompt) {
       let observer = {
@@ -591,40 +604,51 @@ var gPluginHandler = {
       // it from being GC. But I don't want to manually manage the reference's
       // lifetime (which should be no greater than the page).
       // Clever solution? Use a closue with an event listener on the document.
       // When the doc goes away, so do the listener references and the closure.
       doc.addEventListener("mozCleverClosureHack", observer, false);
     }
 #endif
 
-    let crashText = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgCrashed");
+    let crashText = doc.getAnonymousElementByAttribute(plugin, "class", "msgCrashedText");
     crashText.textContent = messageString;
     let browser = tabmail.getBrowserForSelectedTab();
 
     let link = doc.getAnonymousElementByAttribute(plugin, "class", "reloadLink");
     this.addLinkClickCallback(link, "reloadPage", browser);
 
     let notificationBox = getNotificationBox(browser.contentWindow);
 
+    let isShowing = true;
+
     // Is the <object>'s size too small to hold what we want to show?
     if (this.isTooSmall(plugin, overlay)) {
-        // Hide the overlay's contents. Use visibility style, so that it
-        // doesn't collapse down to 0x0.
+      // First try hiding the crash report submission UI.
+      statusDiv.removeAttribute("status");
+
+      if (this.isTooSmall(plugin, overlay)) {
+	// Hide the overlay's contents. Use visibility style, so that it doesn't
+        // collpase down to 0x0.
         overlay.style.visibility = "hidden";
-        // If another plugin on the page was large enough to show our UI, we
-        // don't want to show a notification bar.
-        if (!doc.mozNoPluginCrashedNotification)
-          showNotificationBar(pluginDumpID, browserDumpID);
+        isShowing = false;
+      }
+    }
+
+    if (isShowing) {
+      // If a previous plugin on the page was too small and resulted in adding a
+      // notification bar, then remove it because this plugin instance is big
+      // enough to serve as in-content notification.
+      hideNotificationBar();
+      doc.mozNoPluginCrashedNotification = true;
     } else {
-        // If a previous plugin on the page was too small and resulted in
-        // adding a notification bar, then remove it because this plugin
-        // instance it big enough to serve as in-content notification.
-        hideNotificationBar();
-        doc.mozNoPluginCrashedNotification = true;
+      // If another plugin on the page was large enough to show our UI, we don't
+      // want to show a notification bar.
+      if (!doc.mozNoPluginCrashedNotification)
+        showNotificationBar(pluginDumpID, browserDumpID);
     }
 
     function hideNotificationBar() {
       let notification = notificationBox.getNotificationWithValue("plugin-crashed");
       if (notification)
         notificationBox.removeNotification(notification, true);
     }