From 46f873c5ffa0499759aa3102c80a613d0a94f08d Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 20 Jul 2011 17:52:13 -0700 Subject: [PATCH] Bug 548667 - Future-proof CrashSubmit against future argument additions. r=ted --- browser/base/content/browser.js | 4 +- mobile/chrome/content/browser.js | 2 +- toolkit/crashreporter/CrashSubmit.jsm | 47 +++++++++++++++--------- toolkit/crashreporter/content/crashes.js | 7 +++- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index c3de962b8c0..d803ba6308e 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -6797,9 +6797,9 @@ var gPluginHandler = { submitReport : function(pluginDumpID, browserDumpID) { // The crash reporter wants a DOM element it can append an IFRAME to, // which it uses to submit a form. Let's just give it gBrowser. - this.CrashSubmit.submit(pluginDumpID, null, null); + this.CrashSubmit.submit(pluginDumpID); if (browserDumpID) - this.CrashSubmit.submit(browserDumpID, null, null); + this.CrashSubmit.submit(browserDumpID); }, // Callback for user clicking a "reload page" link diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js index 427486208fe..cd64c1e35eb 100644 --- a/mobile/chrome/content/browser.js +++ b/mobile/chrome/content/browser.js @@ -2527,7 +2527,7 @@ var ContentCrashObserver = { } catch (x) { dump (x); } - self.CrashSubmit.submit(dumpID, null, null); + self.CrashSubmit.submit(dumpID); } }, 0, this); } diff --git a/toolkit/crashreporter/CrashSubmit.jsm b/toolkit/crashreporter/CrashSubmit.jsm index 3a685d9425e..d1a52d789e4 100644 --- a/toolkit/crashreporter/CrashSubmit.jsm +++ b/toolkit/crashreporter/CrashSubmit.jsm @@ -329,29 +329,42 @@ let CrashSubmit = { * * @param id * Filename (minus .dmp extension) of the minidump to submit. - * @param submitSuccess - * A function that will be called if the report is submitted - * successfully with two parameters: the id that was passed - * to this function, and an object containing the key/value - * data returned from the server in its properties. - * @param submitError - * A function that will be called with one parameter if the - * report fails to submit: the id that was passed to this - * 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. + * @param params + * An object containing any of the following optional parameters: + * - submitSuccess + * A function that will be called if the report is submitted + * successfully with two parameters: the id that was passed + * to this function, and an object containing the key/value + * data returned from the server in its properties. + * - submitError + * A function that will be called with one parameter if the + * report fails to submit: the id that was passed to this + * function. + * - 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. Defaults to false. * * @return true if the submission began successfully, or false if * it failed for some reason. (If the dump file does not * exist, for example.) */ - submit: function CrashSubmit_submit(id, submitSuccess, submitError, - noThrottle) + submit: function CrashSubmit_submit(id, params) { + params = params || {}; + let submitSuccess = null; + let submitError = null; + let noThrottle = false; + + if ('submitSuccess' in params) + submitSuccess = params.submitSuccess; + if ('submitError' in params) + submitError = params.submitError; + if ('noThrottle' in params) + noThrottle = params.noThrottle; + let submitter = new Submitter(id, submitSuccess, submitError, diff --git a/toolkit/crashreporter/content/crashes.js b/toolkit/crashreporter/content/crashes.js index 90a670e514c..c2a80d88e9b 100644 --- a/toolkit/crashreporter/content/crashes.js +++ b/toolkit/crashreporter/content/crashes.js @@ -77,8 +77,11 @@ function submitError(dumpid) { function submitPendingReport(event) { var link = event.target; var id = link.firstChild.textContent; - if (CrashSubmit.submit(id, submitSuccess, submitError, true)) - link.className = "submitting"; + if (CrashSubmit.submit(id, { submitSuccess: submitSuccess, + submitError: submitError, + noThrottle: true })) { + link.className = "submitting"; + } event.preventDefault(); return false; }