mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 574357 - Plugin crash reports are submitted with Throttleable=0. r=dolske
--HG-- rename : modules/plugin/test/mochitest/test_crash_notify_no_report.xul => modules/plugin/test/mochitest/test_crash_submit.xul
This commit is contained in:
parent
657620b2b4
commit
17362ddaa6
@ -107,6 +107,7 @@ _MOCHICHROME_FILES = \
|
|||||||
test_bug479979.xul \
|
test_bug479979.xul \
|
||||||
test_crash_notify.xul \
|
test_crash_notify.xul \
|
||||||
test_crash_notify_no_report.xul \
|
test_crash_notify_no_report.xul \
|
||||||
|
test_crash_submit.xul \
|
||||||
test_npruntime.xul \
|
test_npruntime.xul \
|
||||||
test_privatemode.xul \
|
test_privatemode.xul \
|
||||||
test_wmode.xul \
|
test_wmode.xul \
|
||||||
|
128
modules/plugin/test/mochitest/test_crash_submit.xul
Normal file
128
modules/plugin/test/mochitest/test_crash_submit.xul
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||||
|
type="text/css"?>
|
||||||
|
<window title="Basic Plugin Tests"
|
||||||
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
<title>Plugin Crash Notification Test</title>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
|
||||||
|
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
|
||||||
|
</body>
|
||||||
|
<script class="testbody" type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
var crashReporter =
|
||||||
|
Components.classes["@mozilla.org/toolkit/crash-reporter;1"]
|
||||||
|
.getService(Components.interfaces.nsICrashReporter);
|
||||||
|
var oldServerURL = crashReporter.serverURL;
|
||||||
|
|
||||||
|
const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs";
|
||||||
|
|
||||||
|
var testObserver = {
|
||||||
|
observe: function(subject, topic, data) {
|
||||||
|
if (data == "submitting") // not done yet
|
||||||
|
return;
|
||||||
|
is(data, "success", "report should have been submitted successfully");
|
||||||
|
is(topic, "crash-report-status", "Checking correct topic");
|
||||||
|
ok(subject instanceof Components.interfaces.nsIPropertyBag2,
|
||||||
|
"Subject should be a property bag");
|
||||||
|
ok(subject.hasKey("serverCrashID"), "Should have a server crash ID");
|
||||||
|
let crashid = subject.getPropertyAsAString("serverCrashID");
|
||||||
|
|
||||||
|
// Verify the data. The SJS script will return the data that was POSTed
|
||||||
|
let req = new XMLHttpRequest();
|
||||||
|
req.open("GET", SERVER_URL + "?id=" + crashid, false);
|
||||||
|
req.send(null);
|
||||||
|
is(req.status, 200, "Server response should be 200 OK");
|
||||||
|
let submitted = JSON.parse(req.responseText);
|
||||||
|
ok(!("Throttleable" in submitted), "Submit request should not be Throttleable");
|
||||||
|
is(submitted.ProcessType, "plugin", "Should specify ProcessType=plugin");
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
// First remove our fake submitted report
|
||||||
|
let file = Services.dirsvc.get("UAppData", Components.interfaces.nsILocalFile);
|
||||||
|
file.append("Crash Reports");
|
||||||
|
file.append("submitted");
|
||||||
|
file.append(crashid + ".txt");
|
||||||
|
file.remove(false);
|
||||||
|
|
||||||
|
// Next unregister our observer
|
||||||
|
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||||
|
getService(Components.interfaces.nsIObserverService);
|
||||||
|
os.removeObserver(testObserver, "crash-report-status");
|
||||||
|
|
||||||
|
// Then re-set MOZ_CRASHREPORTER_NO_REPORT
|
||||||
|
let env = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
|
.getService(Components.interfaces.nsIEnvironment);
|
||||||
|
env.set("MOZ_CRASHREPORTER_NO_REPORT", "1");
|
||||||
|
|
||||||
|
// Finally re-set crashreporter URL
|
||||||
|
crashReporter.serverURL = oldServerURL;
|
||||||
|
SimpleTest.finish();
|
||||||
|
},
|
||||||
|
|
||||||
|
QueryInterface: function(iid) {
|
||||||
|
if (iid.equals(Components.interfaces.nsIObserver) ||
|
||||||
|
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||||
|
iid.equals(Components.interfaces.nsISupports))
|
||||||
|
return this;
|
||||||
|
throw Components.results.NS_NOINTERFACE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function onPluginCrashed(aEvent) {
|
||||||
|
ok(true, "Plugin crashed notification received");
|
||||||
|
is(aEvent.type, "PluginCrashed", "event is correct type");
|
||||||
|
|
||||||
|
let pleaseLink = document.getAnonymousElementByAttribute(
|
||||||
|
aEvent.target, "class", "pleaseSubmitLink");
|
||||||
|
// try to submit this report
|
||||||
|
sendMouseEvent({type:'click'}, pleaseLink, window);
|
||||||
|
}
|
||||||
|
|
||||||
|
function runTests() {
|
||||||
|
var prefs = Components.classes['@mozilla.org/preferences-service;1']
|
||||||
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
|
if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
|
||||||
|
ok(true, "Skipping this test when IPC plugins are not enabled.");
|
||||||
|
SimpleTest.finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// the test harness will have set MOZ_CRASHREPORTER_NO_REPORT,
|
||||||
|
// ensure that we can change the setting and have our minidumps
|
||||||
|
// wind up in Crash Reports/pending
|
||||||
|
let env = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
|
.getService(Components.interfaces.nsIEnvironment);
|
||||||
|
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
|
||||||
|
|
||||||
|
// Override the crash reporter URL to send to our fake server
|
||||||
|
crashReporter.serverURL = NetUtil.newURI(SERVER_URL);
|
||||||
|
|
||||||
|
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||||
|
getService(Components.interfaces.nsIObserverService);
|
||||||
|
os.addObserver(testObserver, "crash-report-status", true);
|
||||||
|
|
||||||
|
document.addEventListener("PluginCrashed", onPluginCrashed, false);
|
||||||
|
|
||||||
|
var pluginElement = document.getElementById("plugin1");
|
||||||
|
try {
|
||||||
|
pluginElement.crash();
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
</window>
|
||||||
|
|
@ -8,9 +8,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a mouse event to the node with id aTarget. The "event" passed in to
|
* Send a mouse event to the node aTarget (aTarget can be an id, or an
|
||||||
* aEvent is just a JavaScript object with the properties set that the real
|
* actual node) . The "event" passed in to aEvent is just a JavaScript
|
||||||
* mouse event object should have. This includes the type of the mouse event.
|
* object with the properties set that the real mouse event object should
|
||||||
|
* have. This includes the type of the mouse event.
|
||||||
* E.g. to send an click event to the node with id 'node' you might do this:
|
* E.g. to send an click event to the node with id 'node' you might do this:
|
||||||
*
|
*
|
||||||
* sendMouseEvent({type:'click'}, 'node');
|
* sendMouseEvent({type:'click'}, 'node');
|
||||||
@ -24,6 +25,10 @@ function sendMouseEvent(aEvent, aTarget, aWindow) {
|
|||||||
aWindow = window;
|
aWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(aTarget instanceof Element)) {
|
||||||
|
aTarget = aWindow.document.getElementById(aTarget);
|
||||||
|
}
|
||||||
|
|
||||||
// For events to trigger the UA's default actions they need to be "trusted"
|
// For events to trigger the UA's default actions they need to be "trusted"
|
||||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
|
||||||
|
|
||||||
@ -52,7 +57,7 @@ function sendMouseEvent(aEvent, aTarget, aWindow) {
|
|||||||
ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg,
|
ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg,
|
||||||
buttonArg, relatedTargetArg);
|
buttonArg, relatedTargetArg);
|
||||||
|
|
||||||
aWindow.document.getElementById(aTarget).dispatchEvent(event);
|
aTarget.dispatchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,12 +187,13 @@ function writeSubmittedReport(crashID, viewURL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// the Submitter class represents an individual submission.
|
// the Submitter class represents an individual submission.
|
||||||
function Submitter(id, element, submitSuccess, submitError) {
|
function Submitter(id, element, submitSuccess, submitError, noThrottle) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.document = element.ownerDocument;
|
this.document = element.ownerDocument;
|
||||||
this.successCallback = submitSuccess;
|
this.successCallback = submitSuccess;
|
||||||
this.errorCallback = submitError;
|
this.errorCallback = submitError;
|
||||||
|
this.noThrottle = noThrottle;
|
||||||
}
|
}
|
||||||
|
|
||||||
Submitter.prototype = {
|
Submitter.prototype = {
|
||||||
@ -250,8 +251,10 @@ Submitter.prototype = {
|
|||||||
for (let [name, value] in Iterator(reportData)) {
|
for (let [name, value] in Iterator(reportData)) {
|
||||||
addFormEntry(this.iframe.contentDocument, form, name, value);
|
addFormEntry(this.iframe.contentDocument, form, name, value);
|
||||||
}
|
}
|
||||||
// tell the server not to throttle this, since it was manually submitted
|
if (this.noThrottle) {
|
||||||
addFormEntry(this.iframe.contentDocument, form, "Throttleable", "0");
|
// tell the server not to throttle this, since it was manually submitted
|
||||||
|
addFormEntry(this.iframe.contentDocument, form, "Throttleable", "0");
|
||||||
|
}
|
||||||
// add the minidump
|
// add the minidump
|
||||||
this.iframe.contentDocument.getElementById('minidump').value
|
this.iframe.contentDocument.getElementById('minidump').value
|
||||||
= this.dump.path;
|
= this.dump.path;
|
||||||
@ -310,6 +313,9 @@ Submitter.prototype = {
|
|||||||
let propBag = Cc["@mozilla.org/hash-property-bag;1"].
|
let propBag = Cc["@mozilla.org/hash-property-bag;1"].
|
||||||
createInstance(Ci.nsIWritablePropertyBag2);
|
createInstance(Ci.nsIWritablePropertyBag2);
|
||||||
propBag.setPropertyAsAString("minidumpID", this.id);
|
propBag.setPropertyAsAString("minidumpID", this.id);
|
||||||
|
if (status == SUCCESS) {
|
||||||
|
propBag.setPropertyAsAString("serverCrashID", ret.CrashID);
|
||||||
|
}
|
||||||
|
|
||||||
Services.obs.notifyObservers(propBag, "crash-report-status", status);
|
Services.obs.notifyObservers(propBag, "crash-report-status", status);
|
||||||
|
|
||||||
@ -384,14 +390,25 @@ let CrashSubmit = {
|
|||||||
* A function that will be called with one parameter if the
|
* A function that will be called with one parameter if the
|
||||||
* report fails to submit: the id that was passed to this
|
* report fails to submit: the id that was passed to this
|
||||||
* function.
|
* function.
|
||||||
|
* @param noThrottle
|
||||||
|
* If true, this crash report should be submitted with
|
||||||
|
* an extra parameter of "Throttleable=0" indicating that
|
||||||
|
* it should be processed right away. This should be set
|
||||||
|
* when the report is being submitted and the user expects
|
||||||
|
* to see the results immediately.
|
||||||
*
|
*
|
||||||
* @return true if the submission began successfully, or false if
|
* @return true if the submission began successfully, or false if
|
||||||
* it failed for some reason. (If the dump file does not
|
* it failed for some reason. (If the dump file does not
|
||||||
* exist, for example.)
|
* exist, for example.)
|
||||||
*/
|
*/
|
||||||
submit: function CrashSubmit_submit(id, element, submitSuccess, submitError)
|
submit: function CrashSubmit_submit(id, element, submitSuccess, submitError,
|
||||||
|
noThrottle)
|
||||||
{
|
{
|
||||||
let submitter = new Submitter(id, element, submitSuccess, submitError);
|
let submitter = new Submitter(id,
|
||||||
|
element,
|
||||||
|
submitSuccess,
|
||||||
|
submitError,
|
||||||
|
noThrottle);
|
||||||
CrashSubmit._activeSubmissions.push(submitter);
|
CrashSubmit._activeSubmissions.push(submitter);
|
||||||
return submitter.submit();
|
return submitter.submit();
|
||||||
},
|
},
|
||||||
|
@ -77,7 +77,7 @@ function submitError(dumpid) {
|
|||||||
function submitPendingReport(event) {
|
function submitPendingReport(event) {
|
||||||
var link = event.target;
|
var link = event.target;
|
||||||
var id = link.firstChild.textContent;
|
var id = link.firstChild.textContent;
|
||||||
if (CrashSubmit.submit(id, document.body, submitSuccess, submitError))
|
if (CrashSubmit.submit(id, document.body, submitSuccess, submitError, true))
|
||||||
link.className = "submitting";
|
link.className = "submitting";
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user