Bug 1045100 - This is 1 of 2 patches. This patch implements on the front end the new "PluginCrashedEvent" WebIDL binding. r=gfritzsche,mconley
authorConnor <cojojennings@gmail.com>
Wed, 22 Oct 2014 00:41:32 -0400
changeset 240810 f46bc389856da1d7ecbc09b3406d9e1c0bd735f2
parent 240809 b7acf8f21edc6f4336348648cf05bdccb728ff25
child 240811 dcbd5f128917ec1b4ff11e38f7c8338171bee92e
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche, mconley
bugs1045100
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1045100 - This is 1 of 2 patches. This patch implements on the front end the new "PluginCrashedEvent" WebIDL binding. r=gfritzsche,mconley
browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js
browser/modules/PluginContent.jsm
dom/plugins/test/mochitest/hang_test.js
dom/plugins/test/mochitest/test_crash_notify.xul
dom/plugins/test/mochitest/test_crash_notify_no_report.xul
dom/plugins/test/mochitest/test_hangui.xul
--- a/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
+++ b/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
@@ -1,19 +1,21 @@
 /* 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/. */
 
 let gTestBrowser = null;
 
-let propBagProperties = {
+let crashedEventProperties = {
   pluginName: "GlobalTestPlugin",
   pluginDumpID: "1234",
   browserDumpID: "5678",
-  submittedCrashReport: false
+  submittedCrashReport: false,
+  bubbles: true,
+  cancelable: true
 }
 
 // Test that plugin crash submissions still work properly after
 // click-to-play activation.
 
 function test() {
   waitForExplicitFinish();
   let tab = gBrowser.loadOneTab("about:blank", { inBackground: false });
@@ -29,39 +31,30 @@ function test() {
 }
 
 function onPageLoad() {
   executeSoon(generateCrashEvent);
 }
 
 function generateCrashEvent() {
   let window = gTestBrowser.contentWindow;
-  let propBag = Cc["@mozilla.org/hash-property-bag;1"]
-                  .createInstance(Ci.nsIWritablePropertyBag);
-  for (let [name, val] of Iterator(propBagProperties)) {
-    propBag.setProperty(name, val);
-  }
+  let crashedEvent = new window.PluginCrashedEvent("PluginCrashed", crashedEventProperties);
 
-  let event = window.document.createEvent("CustomEvent");
-  event.initCustomEvent("PluginCrashed", true, true, propBag);
-  window.dispatchEvent(event);
+  window.dispatchEvent(crashedEvent);
 }
 
 
 function onCrash(event) {
   let target = event.target;
   is (target, gTestBrowser.contentWindow, "Event target is the window.");
 
-  let propBag = event.detail.QueryInterface(Ci.nsIPropertyBag2);
-  for (let [name, val] of Iterator(propBagProperties)) {
-    let type = typeof val;
-    let propVal = type == "string"
-                  ? propBag.getPropertyAsAString(name)
-                  : propBag.getPropertyAsBool(name);
-    is (propVal, val, "Correct property in detail propBag: " + name + ".");
+  for (let [name, val] of Iterator(crashedEventProperties)) {
+    let propVal = event[name];
+
+    is (propVal, val, "Correct property: " + name + ".");
   }
 
   waitForNotificationBar("plugin-crashed", gTestBrowser, (notification) => {
     let notificationBox = gBrowser.getNotificationBox(gTestBrowser);
     ok(notification, "Infobar was shown.");
     is(notification.priority, notificationBox.PRIORITY_WARNING_MEDIUM, "Correct priority.");
     is(notification.getAttribute("label"), "The GlobalTestPlugin plugin has crashed.", "Correct message.");
     finish();
--- a/browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js
+++ b/browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js
@@ -52,20 +52,18 @@ function frameScript() {
       let style = content.getComputedStyle(getUI("pleaseSubmit"));
       if (style.display != message.data.pleaseSubmitStyle) {
         fail("Submission UI visibility is not correct. Expected " +
              `${message.data.pleaseSubmitStyle} and got ${style.display}`);
         return;
       }
 
       if (message.data.sendCrashMessage) {
-        let propBag = event.detail.QueryInterface(Ci.nsIPropertyBag2);
-        let crashID = propBag.getPropertyAsAString("pluginDumpID");
         sendAsyncMessage("test:crash-plugin:crashed", {
-          crashID: crashID,
+          crashID: event.pluginDumpID,
         });
         return;
       }
 
       if (message.data.submitComment) {
         getUI("submitComment").value = message.data.submitComment;
       }
       getUI("submitURLOptIn").checked = message.data.urlOptIn;
--- a/browser/modules/PluginContent.jsm
+++ b/browser/modules/PluginContent.jsm
@@ -844,40 +844,26 @@ PluginContent.prototype = {
 
   hideNotificationBar: function (name) {
     this.global.sendAsyncMessage("PluginContent:HideNotificationBar", { name: name });
   },
 
   // Crashed-plugin event listener. Called for every instance of a
   // plugin in content.
   pluginInstanceCrashed: function (target, aEvent) {
-    // Ensure the plugin and event are of the right type.
-    if (!(aEvent instanceof Ci.nsIDOMCustomEvent))
+    if (!(aEvent instanceof this.content.PluginCrashedEvent))
       return;
 
-    let propBag = aEvent.detail.QueryInterface(Ci.nsIPropertyBag2);
-    let submittedReport = propBag.getPropertyAsBool("submittedCrashReport");
-    let doPrompt        = true; // XXX followup for .getPropertyAsBool("doPrompt");
-    let submitReports   = true; // XXX followup for .getPropertyAsBool("submitReports");
-    let pluginName      = propBag.getPropertyAsAString("pluginName");
-    let pluginDumpID    = propBag.getPropertyAsAString("pluginDumpID");
-    let browserDumpID   = null;
-    let gmpPlugin       = false;
-
-    try {
-      browserDumpID = propBag.getPropertyAsAString("browserDumpID");
-    } catch (e) {
-      // For GMP crashes we don't get a browser dump.
-    }
-
-    try {
-      gmpPlugin = propBag.getPropertyAsBool("gmpPlugin");
-    } catch (e) {
-      // This property is only set for GMP plugins.
-    }
+    let submittedReport = aEvent.submittedCrashReport;
+    let doPrompt        = true; // XXX followup for aEvent.doPrompt;
+    let submitReports   = true; // XXX followup for aEvent.submitReports;
+    let pluginName      = aEvent.pluginName;
+    let pluginDumpID    = aEvent.pluginDumpID;
+    let browserDumpID   = aEvent.browserDumpID;
+    let gmpPlugin       = aEvent.gmpPlugin;
 
     // For non-GMP plugins, remap the plugin name to a more user-presentable form.
     if (!gmpPlugin) {
       pluginName = BrowserUtils.makeNicePluginName(pluginName);
     }
 
     let messageString = gNavigatorBundle.formatStringFromName("crashedpluginsMessage.title", [pluginName], 1);
 
--- a/dom/plugins/test/mochitest/hang_test.js
+++ b/dom/plugins/test/mochitest/hang_test.js
@@ -87,29 +87,28 @@ var testObserver = {
 function onPluginCrashed(aEvent) {
   ok(true, "Plugin crashed notification received");
   ok(observerFired, "Observer should have fired first");
   is(aEvent.type, "PluginCrashed", "event is correct type");
 
   var pluginElement = document.getElementById("plugin1");
   is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
 
-  ok(aEvent instanceof Ci.nsIDOMCustomEvent,
+  ok(aEvent instanceof PluginCrashedEvent,
      "plugin crashed event has the right interface");
 
-  var propBag = aEvent.detail.QueryInterface(Ci.nsIPropertyBag2);
-  var pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
-  isnot(pluginDumpID, "", "got a non-empty dump ID");
-  var pluginName = propBag.getPropertyAsAString("pluginName");
-  is(pluginName, "Test Plug-in", "got correct plugin name");
-  var pluginFilename = propBag.getPropertyAsAString("pluginFilename");
-  isnot(pluginFilename, "", "got a non-empty filename");
-  var didReport = propBag.getPropertyAsBool("submittedCrashReport");
+  is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
+  isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
+  is(typeof aEvent.pluginName, "string", "pluginName is correct type");
+  is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
+  is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
+  isnot(aEvent.pluginFilename, "", "got a non-empty filename");
   // The app itself may or may not have decided to submit the report, so
   // allow either true or false here.
-  ok((didReport == true || didReport == false), "event said crash report was submitted");
+  ok("submittedCrashReport" in aEvent, "submittedCrashReport is a property of event");
+  is(typeof aEvent.submittedCrashReport, "boolean", "submittedCrashReport is correct type");
 
   var os = Cc["@mozilla.org/observer-service;1"].
            getService(Ci.nsIObserverService);
   os.removeObserver(testObserver, "plugin-crashed");
 
   SimpleTest.finish();
 }
--- a/dom/plugins/test/mochitest/test_crash_notify.xul
+++ b/dom/plugins/test/mochitest/test_crash_notify.xul
@@ -61,30 +61,29 @@ var testObserver = {
 function onPluginCrashed(aEvent) {
   ok(true, "Plugin crashed notification received");
   ok(observerFired, "Observer should have fired first");
   is(aEvent.type, "PluginCrashed", "event is correct type");
 
   var pluginElement = document.getElementById("plugin1");
   is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
 
-  ok(aEvent instanceof Components.interfaces.nsIDOMCustomEvent,
+  ok(aEvent instanceof PluginCrashedEvent,
      "plugin crashed event has the right interface");
 
-  var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
-  var pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
-  isnot(pluginDumpID, "", "got a non-empty dump ID");
-  var pluginName = propBag.getPropertyAsAString("pluginName");
-  is(pluginName, "Test Plug-in", "got correct plugin name");
-  var pluginFilename = propBag.getPropertyAsAString("pluginFilename");
-  isnot(pluginFilename, "", "got a non-empty filename");
-  var didReport = propBag.getPropertyAsBool("submittedCrashReport");
+  is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
+  isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
+  is(typeof aEvent.pluginName, "string", "pluginName is correct type");
+  is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
+  is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
+  isnot(aEvent.pluginFilename, "", "got a non-empty filename");
   // The app itself may or may not have decided to submit the report, so
   // allow either true or false here.
-  ok((didReport == true || didReport == false), "event said crash report was submitted");
+  ok("submittedCrashReport" in aEvent, "submittedCrashReport is a property of event");
+  is(typeof aEvent.submittedCrashReport, "boolean", "submittedCrashReport is correct type");
 
   var os = Components.classes["@mozilla.org/observer-service;1"].
            getService(Components.interfaces.nsIObserverService);
   os.removeObserver(testObserver, "plugin-crashed");
 
   SimpleTest.finish();
 }
 
--- a/dom/plugins/test/mochitest/test_crash_notify_no_report.xul
+++ b/dom/plugins/test/mochitest/test_crash_notify_no_report.xul
@@ -64,25 +64,25 @@ var testObserver = {
 function onPluginCrashed(aEvent) {
   ok(true, "Plugin crashed notification received");
   ok(observerFired, "Observer should have fired first");
   is(aEvent.type, "PluginCrashed", "event is correct type");
 
   var pluginElement = document.getElementById("plugin1");
   is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
 
-  ok(aEvent instanceof Components.interfaces.nsIDOMCustomEvent,
+  ok(aEvent instanceof PluginCrashedEvent,
      "plugin crashed event has the right interface");
-  var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
-  var pluginName = propBag.getPropertyAsAString("pluginName");
-  is(pluginName, "Test Plug-in");
-  var didReport = propBag.getPropertyAsBool("submittedCrashReport");
+
+  is(typeof aEvent.pluginName, "string", "pluginName is correct type");
+  is(aEvent.pluginName, "Test Plug-in");
   // The app itself may or may not have decided to submit the report, so
   // allow either true or false here.
-  ok((didReport == true || didReport == false), "event said crash report was submitted");
+  ok("submittedCrashReport" in aEvent, "submittedCrashReport is a property of event");
+  is(typeof aEvent.submittedCrashReport, "boolean", "submittedCrashReport is correct type");
 
   var os = Components.classes["@mozilla.org/observer-service;1"].
            getService(Components.interfaces.nsIObserverService);
   os.removeObserver(testObserver, "plugin-crashed");
 
   // re-set MOZ_CRASHREPORTER_NO_REPORT
   let env = Components.classes["@mozilla.org/process/environment;1"]
                       .getService(Components.interfaces.nsIEnvironment);
--- a/dom/plugins/test/mochitest/test_hangui.xul
+++ b/dom/plugins/test/mochitest/test_hangui.xul
@@ -112,30 +112,30 @@ window.frameLoaded = runTests;
 var obsCount = 0;
 
 function onPluginCrashedHangUI(aEvent) {
   ok(true, "Plugin crashed notification received");
   is(aEvent.type, "PluginCrashed", "event is correct type");
 
   is(p, aEvent.target, "Plugin crashed event target is plugin element");
 
-  ok(aEvent instanceof Components.interfaces.nsIDOMCustomEvent,
+  ok(aEvent instanceof PluginCrashedEvent,
      "plugin crashed event has the right interface");
 
-  var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
-  var pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
-  isnot(pluginDumpID, "", "got a non-empty dump ID");
-  var pluginName = propBag.getPropertyAsAString("pluginName");
-  is(pluginName, "Test Plug-in", "got correct plugin name");
-  var pluginFilename = propBag.getPropertyAsAString("pluginFilename");
-  isnot(pluginFilename, "", "got a non-empty filename");
-  var didReport = propBag.getPropertyAsBool("submittedCrashReport");
+  is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
+  isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
+  is(typeof aEvent.pluginName, "string", "pluginName is correct type");
+  is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
+  is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
+  isnot(aEvent.pluginFilename, "", "got a non-empty filename");
   // The app itself may or may not have decided to submit the report, so
   // allow either true or false here.
-  ok((didReport == true || didReport == false), "event said crash report was submitted");
+  ok("submittedCrashReport" in aEvent, "submittedCrashReport is a property of event");
+  is(typeof aEvent.submittedCrashReport, "boolean", "submittedCrashReport is correct type");
+
   os.removeObserver(testObserver, "plugin-crashed");
   --obsCount;
 }
 
 function resetVars() {
   iframe = document.getElementById('iframe1');
   p = iframe.contentDocument.getElementById("plugin1");
   if (obsCount == 0) {