From 8d893ad5975a221b9cce4099d5b418de8a105d68 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Mon, 11 Jan 2010 15:13:12 -0500 Subject: [PATCH] Bug 539048 - Hacky temporary UI for sending plugin-process crash reports, r=ted --HG-- extra : rebase_source : 6e58afb201aac90a32bacbffbebf79dfa56e7880 --- toolkit/crashreporter/content/crashes.js | 37 ++++++---- .../crashreporter/content/oopcrashdialog.js | 73 +++++++++++++++++++ .../crashreporter/content/oopcrashdialog.xul | 33 +++++++++ .../windows/handler/exception_handler.cc | 3 +- toolkit/crashreporter/jar.mn | 2 + toolkit/crashreporter/nsExceptionHandler.cpp | 40 +++++++++- 6 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 toolkit/crashreporter/content/oopcrashdialog.js create mode 100644 toolkit/crashreporter/content/oopcrashdialog.xul diff --git a/toolkit/crashreporter/content/crashes.js b/toolkit/crashreporter/content/crashes.js index d4a2922446d..b59df00e9b6 100644 --- a/toolkit/crashreporter/content/crashes.js +++ b/toolkit/crashreporter/content/crashes.js @@ -144,17 +144,22 @@ function submitSuccess(ret, link, dump, extra) { // report an error? not much the user can do here. } - // reset the link to point at our new crash report. this way, if the - // user clicks "Back", the link will be correct. - let CrashID = ret.CrashID; - link.firstChild.textContent = CrashID; - link.setAttribute("id", CrashID); - link.removeEventListener("click", submitPendingReport, true); + if (link) { + // reset the link to point at our new crash report. this way, if the + // user clicks "Back", the link will be correct. + let CrashID = ret.CrashID; + link.firstChild.textContent = CrashID; + link.setAttribute("id", CrashID); + link.removeEventListener("click", submitPendingReport, true); - if (reportURL) { - link.setAttribute("href", reportURL + CrashID); - // redirect the user to their brand new crash report - window.location.href = reportURL + CrashID; + if (reportURL) { + link.setAttribute("href", reportURL + CrashID); + // redirect the user to their brand new crash report + window.location.href = reportURL + CrashID; + } + } + else { + window.close(); } } @@ -194,7 +199,8 @@ function submitForm(iframe, dump, extra, link) if(aFlag & STATE_STOP) { iframe.docShell.removeProgressListener(myListener); myListener = null; - link.className = ""; + if (link) + link.className = ""; //XXX: give some indication of failure? // check general request status first @@ -233,12 +239,15 @@ function createAndSubmitForm(id, link) { return false; let iframe = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "iframe"); iframe.setAttribute("type", "content"); - iframe.onload = function() { + + function loadHandler() { if (iframe.contentWindow.location == "about:blank") return; - iframe.onload = null; + iframe.removeEventListener("load", loadHandler, true); submitForm(iframe, dump, extra, link); - }; + } + + iframe.addEventListener("load", loadHandler, true); document.body.appendChild(iframe); iframe.webNavigation.loadURI("chrome://global/content/crash-submit-form.xhtml", 0, null, null, null); return true; diff --git a/toolkit/crashreporter/content/oopcrashdialog.js b/toolkit/crashreporter/content/oopcrashdialog.js new file mode 100644 index 00000000000..539e96d0ad5 --- /dev/null +++ b/toolkit/crashreporter/content/oopcrashdialog.js @@ -0,0 +1,73 @@ +// This code is TEMPORARY for submitting crashes via an ugly popup dialog: +// bug 525849 tracks the real implementation. + +var id; + +function getExtraData() { + let appData = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime); + appData.QueryInterface(Ci.nsICrashReporter); + appData.QueryInterface(Ci.nsIXULAppInfo); + + let r = ""; + r += "ServerURL=" + appData.serverURL.spec + "\n"; + r += "BuildID=" + appData.appBuildID + "\n"; + r += "ProductName=" + appData.name + "\n"; + r += "Vendor=" + appData.vendor + "\n"; + r += "Version=" + appData.version + "\n"; + r += "CrashTime=" + ((new Date()).getTime() / 1000).toFixed() + "\n"; + r += "ProcessType=plugin\n"; + return r; +} + +function collectData() { + // HACK: crashes.js uses document.body, so we just alias it + document.body = document.getElementById('iframe-holder'); + + getL10nStrings(); + + let directoryService = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties); + pendingDir = directoryService.get("UAppData", Ci.nsIFile); + pendingDir.append("Crash Reports"); + pendingDir.append("pending"); + if (!pendingDir.exists()) + pendingDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0770); + + reportsDir = directoryService.get("UAppData", Ci.nsIFile); + reportsDir.append("Crash Reports"); + reportsDir.append("submitted"); + if (!reportsDir.exists()) + reportsDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0770); + + let dumpFile = window.arguments[0].QueryInterface(Ci.nsIFile); + dumpFile.moveTo(pendingDir, ""); + let leafName = dumpFile.leafName; + + id = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.dmp/(leafName)[1]; + + dumpFile = pendingDir.clone(); + dumpFile.append(leafName); + + let extraFile = pendingDir.clone(); + extraFile.append(id + ".extra"); + + let fstream = Cc["@mozilla.org/network/file-output-stream;1"]. + createInstance(Ci.nsIFileOutputStream); + fstream.init(extraFile, -1, -1, 0); + + var os = Cc["@mozilla.org/intl/converter-output-stream;1"]. + createInstance(Ci.nsIConverterOutputStream); + os.init(fstream, "UTF-8", 0, 0x0000); + os.writeString(getExtraData()); + os.close(); + fstream.close(); +} + +function onSubmit() +{ + document.documentElement.getButton('accept').disabled = true; + document.documentElement.getButton('accept').label = 'Sending'; + document.getElementById('throbber').src = 'chrome://global/skin/icons/loading_16.png'; + createAndSubmitForm(id, null); + return false; +} diff --git a/toolkit/crashreporter/content/oopcrashdialog.xul b/toolkit/crashreporter/content/oopcrashdialog.xul new file mode 100644 index 00000000000..4180d30edf5 --- /dev/null +++ b/toolkit/crashreporter/content/oopcrashdialog.xul @@ -0,0 +1,33 @@ + + + + + + + + +