Bug 1045100 - This is 1 of 2 patches. This patch implements on the front end the new "PluginCrashedEvent" WebIDL binding. r=gfritzsche,mconley

This commit is contained in:
Connor 2014-10-22 00:41:32 -04:00
Родитель 2d96083f3d
Коммит 6ac643be3c
7 изменённых файлов: 53 добавлений и 78 удалений

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

@ -4,11 +4,13 @@
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
@ -34,15 +36,9 @@ function onPageLoad() {
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);
}
@ -50,13 +46,10 @@ 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) => {

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

@ -57,10 +57,8 @@ function frameScript() {
}
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;
}

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

@ -849,30 +849,16 @@ PluginContent.prototype = {
// 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) {

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

@ -92,20 +92,19 @@ function onPluginCrashed(aEvent) {
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);

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

@ -66,20 +66,19 @@ function onPluginCrashed(aEvent) {
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);

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

@ -69,15 +69,15 @@ function onPluginCrashed(aEvent) {
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);

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

@ -117,20 +117,20 @@ function onPluginCrashedHangUI(aEvent) {
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;
}