mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
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:
parent
2d96083f3d
commit
6ac643be3c
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
let gTestBrowser = null;
|
let gTestBrowser = null;
|
||||||
|
|
||||||
let propBagProperties = {
|
let crashedEventProperties = {
|
||||||
pluginName: "GlobalTestPlugin",
|
pluginName: "GlobalTestPlugin",
|
||||||
pluginDumpID: "1234",
|
pluginDumpID: "1234",
|
||||||
browserDumpID: "5678",
|
browserDumpID: "5678",
|
||||||
submittedCrashReport: false
|
submittedCrashReport: false,
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that plugin crash submissions still work properly after
|
// Test that plugin crash submissions still work properly after
|
||||||
@ -34,15 +36,9 @@ function onPageLoad() {
|
|||||||
|
|
||||||
function generateCrashEvent() {
|
function generateCrashEvent() {
|
||||||
let window = gTestBrowser.contentWindow;
|
let window = gTestBrowser.contentWindow;
|
||||||
let propBag = Cc["@mozilla.org/hash-property-bag;1"]
|
let crashedEvent = new window.PluginCrashedEvent("PluginCrashed", crashedEventProperties);
|
||||||
.createInstance(Ci.nsIWritablePropertyBag);
|
|
||||||
for (let [name, val] of Iterator(propBagProperties)) {
|
|
||||||
propBag.setProperty(name, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
let event = window.document.createEvent("CustomEvent");
|
window.dispatchEvent(crashedEvent);
|
||||||
event.initCustomEvent("PluginCrashed", true, true, propBag);
|
|
||||||
window.dispatchEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,13 +46,10 @@ function onCrash(event) {
|
|||||||
let target = event.target;
|
let target = event.target;
|
||||||
is (target, gTestBrowser.contentWindow, "Event target is the window.");
|
is (target, gTestBrowser.contentWindow, "Event target is the window.");
|
||||||
|
|
||||||
let propBag = event.detail.QueryInterface(Ci.nsIPropertyBag2);
|
for (let [name, val] of Iterator(crashedEventProperties)) {
|
||||||
for (let [name, val] of Iterator(propBagProperties)) {
|
let propVal = event[name];
|
||||||
let type = typeof val;
|
|
||||||
let propVal = type == "string"
|
is (propVal, val, "Correct property: " + name + ".");
|
||||||
? propBag.getPropertyAsAString(name)
|
|
||||||
: propBag.getPropertyAsBool(name);
|
|
||||||
is (propVal, val, "Correct property in detail propBag: " + name + ".");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForNotificationBar("plugin-crashed", gTestBrowser, (notification) => {
|
waitForNotificationBar("plugin-crashed", gTestBrowser, (notification) => {
|
||||||
|
@ -57,10 +57,8 @@ function frameScript() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.data.sendCrashMessage) {
|
if (message.data.sendCrashMessage) {
|
||||||
let propBag = event.detail.QueryInterface(Ci.nsIPropertyBag2);
|
|
||||||
let crashID = propBag.getPropertyAsAString("pluginDumpID");
|
|
||||||
sendAsyncMessage("test:crash-plugin:crashed", {
|
sendAsyncMessage("test:crash-plugin:crashed", {
|
||||||
crashID: crashID,
|
crashID: event.pluginDumpID,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -849,30 +849,16 @@ PluginContent.prototype = {
|
|||||||
// Crashed-plugin event listener. Called for every instance of a
|
// Crashed-plugin event listener. Called for every instance of a
|
||||||
// plugin in content.
|
// plugin in content.
|
||||||
pluginInstanceCrashed: function (target, aEvent) {
|
pluginInstanceCrashed: function (target, aEvent) {
|
||||||
// Ensure the plugin and event are of the right type.
|
if (!(aEvent instanceof this.content.PluginCrashedEvent))
|
||||||
if (!(aEvent instanceof Ci.nsIDOMCustomEvent))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let propBag = aEvent.detail.QueryInterface(Ci.nsIPropertyBag2);
|
let submittedReport = aEvent.submittedCrashReport;
|
||||||
let submittedReport = propBag.getPropertyAsBool("submittedCrashReport");
|
let doPrompt = true; // XXX followup for aEvent.doPrompt;
|
||||||
let doPrompt = true; // XXX followup for .getPropertyAsBool("doPrompt");
|
let submitReports = true; // XXX followup for aEvent.submitReports;
|
||||||
let submitReports = true; // XXX followup for .getPropertyAsBool("submitReports");
|
let pluginName = aEvent.pluginName;
|
||||||
let pluginName = propBag.getPropertyAsAString("pluginName");
|
let pluginDumpID = aEvent.pluginDumpID;
|
||||||
let pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
|
let browserDumpID = aEvent.browserDumpID;
|
||||||
let browserDumpID = null;
|
let gmpPlugin = aEvent.gmpPlugin;
|
||||||
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.
|
|
||||||
}
|
|
||||||
|
|
||||||
// For non-GMP plugins, remap the plugin name to a more user-presentable form.
|
// For non-GMP plugins, remap the plugin name to a more user-presentable form.
|
||||||
if (!gmpPlugin) {
|
if (!gmpPlugin) {
|
||||||
|
@ -92,20 +92,19 @@ function onPluginCrashed(aEvent) {
|
|||||||
var pluginElement = document.getElementById("plugin1");
|
var pluginElement = document.getElementById("plugin1");
|
||||||
is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
|
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");
|
"plugin crashed event has the right interface");
|
||||||
|
|
||||||
var propBag = aEvent.detail.QueryInterface(Ci.nsIPropertyBag2);
|
is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
|
||||||
var pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
|
isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
|
||||||
isnot(pluginDumpID, "", "got a non-empty dump ID");
|
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
|
||||||
var pluginName = propBag.getPropertyAsAString("pluginName");
|
is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
|
||||||
is(pluginName, "Test Plug-in", "got correct plugin name");
|
is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
|
||||||
var pluginFilename = propBag.getPropertyAsAString("pluginFilename");
|
isnot(aEvent.pluginFilename, "", "got a non-empty filename");
|
||||||
isnot(pluginFilename, "", "got a non-empty filename");
|
|
||||||
var didReport = propBag.getPropertyAsBool("submittedCrashReport");
|
|
||||||
// The app itself may or may not have decided to submit the report, so
|
// The app itself may or may not have decided to submit the report, so
|
||||||
// allow either true or false here.
|
// 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"].
|
var os = Cc["@mozilla.org/observer-service;1"].
|
||||||
getService(Ci.nsIObserverService);
|
getService(Ci.nsIObserverService);
|
||||||
|
@ -66,20 +66,19 @@ function onPluginCrashed(aEvent) {
|
|||||||
var pluginElement = document.getElementById("plugin1");
|
var pluginElement = document.getElementById("plugin1");
|
||||||
is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
|
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");
|
"plugin crashed event has the right interface");
|
||||||
|
|
||||||
var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
|
is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
|
||||||
var pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
|
isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
|
||||||
isnot(pluginDumpID, "", "got a non-empty dump ID");
|
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
|
||||||
var pluginName = propBag.getPropertyAsAString("pluginName");
|
is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
|
||||||
is(pluginName, "Test Plug-in", "got correct plugin name");
|
is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
|
||||||
var pluginFilename = propBag.getPropertyAsAString("pluginFilename");
|
isnot(aEvent.pluginFilename, "", "got a non-empty filename");
|
||||||
isnot(pluginFilename, "", "got a non-empty filename");
|
|
||||||
var didReport = propBag.getPropertyAsBool("submittedCrashReport");
|
|
||||||
// The app itself may or may not have decided to submit the report, so
|
// The app itself may or may not have decided to submit the report, so
|
||||||
// allow either true or false here.
|
// 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"].
|
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||||
getService(Components.interfaces.nsIObserverService);
|
getService(Components.interfaces.nsIObserverService);
|
||||||
|
@ -69,15 +69,15 @@ function onPluginCrashed(aEvent) {
|
|||||||
var pluginElement = document.getElementById("plugin1");
|
var pluginElement = document.getElementById("plugin1");
|
||||||
is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
|
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");
|
"plugin crashed event has the right interface");
|
||||||
var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
|
|
||||||
var pluginName = propBag.getPropertyAsAString("pluginName");
|
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
|
||||||
is(pluginName, "Test Plug-in");
|
is(aEvent.pluginName, "Test Plug-in");
|
||||||
var didReport = propBag.getPropertyAsBool("submittedCrashReport");
|
|
||||||
// The app itself may or may not have decided to submit the report, so
|
// The app itself may or may not have decided to submit the report, so
|
||||||
// allow either true or false here.
|
// 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"].
|
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||||
getService(Components.interfaces.nsIObserverService);
|
getService(Components.interfaces.nsIObserverService);
|
||||||
|
@ -117,20 +117,20 @@ function onPluginCrashedHangUI(aEvent) {
|
|||||||
|
|
||||||
is(p, aEvent.target, "Plugin crashed event target is plugin element");
|
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");
|
"plugin crashed event has the right interface");
|
||||||
|
|
||||||
var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
|
is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
|
||||||
var pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
|
isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
|
||||||
isnot(pluginDumpID, "", "got a non-empty dump ID");
|
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
|
||||||
var pluginName = propBag.getPropertyAsAString("pluginName");
|
is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
|
||||||
is(pluginName, "Test Plug-in", "got correct plugin name");
|
is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
|
||||||
var pluginFilename = propBag.getPropertyAsAString("pluginFilename");
|
isnot(aEvent.pluginFilename, "", "got a non-empty filename");
|
||||||
isnot(pluginFilename, "", "got a non-empty filename");
|
|
||||||
var didReport = propBag.getPropertyAsBool("submittedCrashReport");
|
|
||||||
// The app itself may or may not have decided to submit the report, so
|
// The app itself may or may not have decided to submit the report, so
|
||||||
// allow either true or false here.
|
// 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");
|
os.removeObserver(testObserver, "plugin-crashed");
|
||||||
--obsCount;
|
--obsCount;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user