summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/test/browser
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/crashreporter/test/browser')
-rw-r--r--toolkit/crashreporter/test/browser/.eslintrc.js7
-rw-r--r--toolkit/crashreporter/test/browser/browser.ini8
-rw-r--r--toolkit/crashreporter/test/browser/browser_aboutCrashes.js27
-rw-r--r--toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js152
-rw-r--r--toolkit/crashreporter/test/browser/browser_bug471404.js41
-rw-r--r--toolkit/crashreporter/test/browser/browser_clearReports.js124
-rw-r--r--toolkit/crashreporter/test/browser/crashreport.sjs180
-rw-r--r--toolkit/crashreporter/test/browser/head.js139
8 files changed, 0 insertions, 678 deletions
diff --git a/toolkit/crashreporter/test/browser/.eslintrc.js b/toolkit/crashreporter/test/browser/.eslintrc.js
deleted file mode 100644
index c764b133d..000000000
--- a/toolkit/crashreporter/test/browser/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = {
- "extends": [
- "../../../../testing/mochitest/browser.eslintrc.js"
- ]
-};
diff --git a/toolkit/crashreporter/test/browser/browser.ini b/toolkit/crashreporter/test/browser/browser.ini
deleted file mode 100644
index b58176571..000000000
--- a/toolkit/crashreporter/test/browser/browser.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[DEFAULT]
-support-files =
- head.js
-
-[browser_aboutCrashes.js]
-[browser_aboutCrashesResubmit.js]
-[browser_bug471404.js]
-[browser_clearReports.js]
diff --git a/toolkit/crashreporter/test/browser/browser_aboutCrashes.js b/toolkit/crashreporter/test/browser/browser_aboutCrashes.js
deleted file mode 100644
index 1293df030..000000000
--- a/toolkit/crashreporter/test/browser/browser_aboutCrashes.js
+++ /dev/null
@@ -1,27 +0,0 @@
-add_task(function* test() {
- let appD = make_fake_appdir();
- let crD = appD.clone();
- crD.append("Crash Reports");
- let crashes = add_fake_crashes(crD, 5);
- // sanity check
- let dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
- .getService(Components.interfaces.nsIProperties);
- let appDtest = dirSvc.get("UAppData", Components.interfaces.nsILocalFile);
- ok(appD.equals(appDtest), "directory service provider registered ok");
-
- yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:crashes" }, function (browser) {
- info("about:crashes loaded");
- return ContentTask.spawn(browser, crashes, function (crashes) {
- let doc = content.document;
- let crashlinks = doc.getElementById("submitted").querySelectorAll(".crashReport");
- Assert.equal(crashlinks.length, crashes.length,
- "about:crashes lists correct number of crash reports");
- for (let i = 0; i < crashes.length; i++) {
- Assert.equal(crashlinks[i].firstChild.textContent, crashes[i].id,
- i + ": crash ID is correct");
- }
- });
- });
-
- cleanup_fake_appdir();
-});
diff --git a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js
deleted file mode 100644
index a911c67e8..000000000
--- a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js
+++ /dev/null
@@ -1,152 +0,0 @@
-function cleanup_and_finish() {
- try {
- cleanup_fake_appdir();
- } catch (ex) {}
- Services.prefs.clearUserPref("breakpad.reportURL");
- BrowserTestUtils.removeTab(gBrowser.selectedTab).then(finish);
-}
-
-/*
- * check_crash_list
- *
- * Check that the list of crashes displayed by about:crashes matches
- * the list of crashes that we placed in the pending+submitted directories.
- *
- * NB: This function is run in the child process via ContentTask.spawn.
- */
-function check_crash_list(crashes) {
- let doc = content.document;
- let crashlinks = doc.getElementsByClassName("crashReport");
- Assert.equal(crashlinks.length, crashes.length,
- "about:crashes lists correct number of crash reports");
- // no point in checking this if the lists aren't the same length
- if (crashlinks.length == crashes.length) {
- for (let i=0; i<crashes.length; i++) {
- Assert.equal(crashlinks[i].id, crashes[i].id, i + ": crash ID is correct");
- if (crashes[i].pending) {
- // we set the breakpad.reportURL pref in test()
- Assert.equal(crashlinks[i].getAttribute("href"),
- "http://example.com/browser/toolkit/crashreporter/about/throttling",
- "pending URL links to the correct static page");
- }
- }
- }
-}
-
-/*
- * check_submit_pending
- *
- * Click on a pending crash in about:crashes, wait for it to be submitted (which
- * should redirect us to the crash report page). Verify that the data provided
- * by our test crash report server matches the data we submitted.
- * Additionally, click "back" and verify that the link now points to our new
- */
-function check_submit_pending(tab, crashes) {
- let browser = gBrowser.getBrowserForTab(tab);
- let SubmittedCrash = null;
- let CrashID = null;
- let CrashURL = null;
- function csp_onload() {
- // loaded the crash report page
- ok(true, 'got submission onload');
-
- ContentTask.spawn(browser, null, function() {
- // grab the Crash ID here to verify later
- let CrashID = content.location.search.split("=")[1];
- let CrashURL = content.location.toString();
-
- // check the JSON content vs. what we submitted
- let result = JSON.parse(content.document.documentElement.textContent);
- Assert.equal(result.upload_file_minidump, "MDMP", "minidump file sent properly");
- Assert.equal(result.memory_report, "Let's pretend this is a memory report",
- "memory report sent properly");
- Assert.equal(+result.Throttleable, 0, "correctly sent as non-throttleable");
- // we checked these, they're set by the submission process,
- // so they won't be in the "extra" data.
- delete result.upload_file_minidump;
- delete result.memory_report;
- delete result.Throttleable;
-
- return { id: CrashID, url: CrashURL, result };
- }).then(({ id, url, result }) => {
- // Likewise, this is discarded before it gets to the server
- delete SubmittedCrash.extra.ServerURL;
-
- CrashID = id;
- CrashURL = url;
- for (let x in result) {
- if (x in SubmittedCrash.extra)
- is(result[x], SubmittedCrash.extra[x],
- "submitted value for " + x + " matches expected");
- else
- ok(false, "property " + x + " missing from submitted data!");
- }
- for (let y in SubmittedCrash.extra) {
- if (!(y in result))
- ok(false, "property " + y + " missing from result data!");
- }
-
- // NB: Despite appearances, this doesn't use a CPOW.
- BrowserTestUtils.waitForEvent(browser, "pageshow", true).then(csp_pageshow);
-
- // now navigate back
- browser.goBack();
- });
- }
- function csp_fail() {
- browser.removeEventListener("CrashSubmitFailed", csp_fail, true);
- ok(false, "failed to submit crash report!");
- cleanup_and_finish();
- }
- browser.addEventListener("CrashSubmitFailed", csp_fail, true);
- BrowserTestUtils.browserLoaded(browser, false, (url) => url !== "about:crashes").then(csp_onload);
- function csp_pageshow() {
- ContentTask.spawn(browser, { CrashID, CrashURL }, function({ CrashID, CrashURL }) {
- Assert.equal(content.location.href, "about:crashes", "navigated back successfully");
- let link = content.document.getElementById(CrashID);
- Assert.notEqual(link, null, "crash report link changed correctly");
- if (link)
- Assert.equal(link.href, CrashURL, "crash report link points to correct href");
- }).then(cleanup_and_finish);
- }
-
- // try submitting the pending report
- for (let crash of crashes) {
- if (crash.pending) {
- SubmittedCrash = crash;
- break;
- }
- }
-
- ContentTask.spawn(browser, SubmittedCrash.id, function(id) {
- let link = content.document.getElementById(id);
- link.click();
- });
-}
-
-function test() {
- waitForExplicitFinish();
- let appD = make_fake_appdir();
- let crD = appD.clone();
- crD.append("Crash Reports");
- let crashes = add_fake_crashes(crD, 1);
- // we don't need much data here, it's not going to a real Socorro
- crashes.push(addPendingCrashreport(crD,
- crashes[crashes.length - 1].date + 60000,
- {'ServerURL': 'http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs',
- 'ProductName': 'Test App',
- // test that we don't truncate
- // at = (bug 512853)
- 'Foo': 'ABC=XYZ'
- }));
- crashes.sort((a, b) => b.date - a.date);
-
- // set this pref so we can link to our test server
- Services.prefs.setCharPref("breakpad.reportURL",
- "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs?id=");
-
- BrowserTestUtils.openNewForegroundTab(gBrowser, "about:crashes").then((tab) => {
- ContentTask.spawn(tab.linkedBrowser, crashes, check_crash_list)
- .then(() => check_submit_pending(tab, crashes));
- });
-}
diff --git a/toolkit/crashreporter/test/browser/browser_bug471404.js b/toolkit/crashreporter/test/browser/browser_bug471404.js
deleted file mode 100644
index f0eb00b71..000000000
--- a/toolkit/crashreporter/test/browser/browser_bug471404.js
+++ /dev/null
@@ -1,41 +0,0 @@
-function check_clear_visible(browser, aVisible) {
- return ContentTask.spawn(browser, aVisible, function (aVisible) {
- let doc = content.document;
- let visible = false;
- let button = doc.getElementById("clear-reports");
- if (button) {
- let style = doc.defaultView.getComputedStyle(button, "");
- if (style.display != "none" &&
- style.visibility == "visible")
- visible = true;
- }
- Assert.equal(visible, aVisible,
- "clear reports button is " + (aVisible ? "visible" : "hidden"));
- });
-}
-
-// each test here has a setup (run before loading about:crashes) and onload (run after about:crashes loads)
-var _tests = [{setup: null, onload: function(browser) { return check_clear_visible(browser, false); }},
- {setup: function(crD) { return add_fake_crashes(crD, 1); },
- onload: function(browser) { return check_clear_visible(browser, true); }}
- ];
-
-add_task(function* test() {
- let appD = make_fake_appdir();
- let crD = appD.clone();
- crD.append("Crash Reports");
-
- yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) {
- for (let test of _tests) {
- // Run setup before loading about:crashes.
- if (test.setup) {
- yield test.setup(crD);
- }
-
- BrowserTestUtils.loadURI(browser, "about:crashes");
- yield BrowserTestUtils.browserLoaded(browser).then(() => test.onload(browser));
- }
- });
-
- cleanup_fake_appdir();
-});
diff --git a/toolkit/crashreporter/test/browser/browser_clearReports.js b/toolkit/crashreporter/test/browser/browser_clearReports.js
deleted file mode 100644
index a7a1780a9..000000000
--- a/toolkit/crashreporter/test/browser/browser_clearReports.js
+++ /dev/null
@@ -1,124 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-function clickClearReports(browser) {
- let doc = content.document;
-
- let button = doc.getElementById("clear-reports");
-
- if (!button) {
- Assert.ok(false, "Button not found");
- return Promise.resolve();
- }
-
- let style = doc.defaultView.getComputedStyle(button, "");
-
- Assert.notEqual(style.display, "none", "Clear reports button visible");
-
- let deferred = {};
- deferred.promise = new Promise(resolve => deferred.resolve = resolve);
- var observer = new content.MutationObserver(function(mutations) {
- for (let mutation of mutations) {
- if (mutation.type == "attributes" &&
- mutation.attributeName == "style") {
- observer.disconnect();
- Assert.equal(style.display, "none", "Clear reports button hidden");
- deferred.resolve();
- }
- }
- });
- observer.observe(button, {
- attributes: true,
- childList: true,
- characterData: true,
- attributeFilter: ["style"],
- });
-
- button.click();
- return deferred.promise;
-}
-
-var promptShown = false;
-
-var oldPrompt = Services.prompt;
-Services.prompt = {
- confirm: function() {
- promptShown = true;
- return true;
- },
-};
-
-registerCleanupFunction(function () {
- Services.prompt = oldPrompt;
-});
-
-add_task(function* test() {
- let appD = make_fake_appdir();
- let crD = appD.clone();
- crD.append("Crash Reports");
-
- // Add crashes to submitted dir
- let submitdir = crD.clone();
- submitdir.append("submitted");
-
- let file1 = submitdir.clone();
- file1.append("bp-nontxt");
- file1.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
- let file2 = submitdir.clone();
- file2.append("nonbp-file.txt");
- file2.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
- add_fake_crashes(crD, 5);
-
- // Add crashes to pending dir
- let pendingdir = crD.clone();
- pendingdir.append("pending");
-
- let crashes = add_fake_crashes(crD, 2);
- addPendingCrashreport(crD, crashes[0].date);
- addPendingCrashreport(crD, crashes[1].date);
-
- // Add crashes to reports dir
- let report1 = crD.clone();
- report1.append("NotInstallTime777");
- report1.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
- let report2 = crD.clone();
- report2.append("InstallTime" + Services.appinfo.appBuildID);
- report2.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
- let report3 = crD.clone();
- report3.append("InstallTimeNew");
- report3.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
- let report4 = crD.clone();
- report4.append("InstallTimeOld");
- report4.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
- report4.lastModifiedTime = Date.now() - 63172000000;
-
- registerCleanupFunction(function () {
- cleanup_fake_appdir();
- });
-
- yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:crashes" },
- function* (browser) {
- let dirs = [ submitdir, pendingdir, crD ];
- let existing = [ file1.path, file2.path, report1.path, report2.path,
- report3.path, submitdir.path, pendingdir.path ];
-
- yield ContentTask.spawn(browser, null, clickClearReports);
-
- for (let dir of dirs) {
- let entries = dir.directoryEntries;
- while (entries.hasMoreElements()) {
- let file = entries.getNext().QueryInterface(Ci.nsIFile);
- let index = existing.indexOf(file.path);
- isnot(index, -1, file.leafName + " exists");
-
- if (index != -1) {
- existing.splice(index, 1);
- }
- }
- }
-
- is(existing.length, 0, "All the files that should still exist exist");
- ok(promptShown, "Prompt shown");
- });
-});
diff --git a/toolkit/crashreporter/test/browser/crashreport.sjs b/toolkit/crashreporter/test/browser/crashreport.sjs
deleted file mode 100644
index f3bd858eb..000000000
--- a/toolkit/crashreporter/test/browser/crashreport.sjs
+++ /dev/null
@@ -1,180 +0,0 @@
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const CC = Components.Constructor;
-
-const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
- "nsIBinaryInputStream",
- "setInputStream");
-
-function parseHeaders(data, start)
-{
- let headers = {};
-
- while (true) {
- let done = false;
- let end = data.indexOf("\r\n", start);
- if (end == -1) {
- done = true;
- end = data.length;
- }
- let line = data.substring(start, end);
- start = end + 2;
- if (line == "")
- // empty line, we're done
- break;
-
- //XXX: this doesn't handle multi-line headers. do we care?
- let [name, value] = line.split(':');
- //XXX: not normalized, should probably use nsHttpHeaders or something
- headers[name] = value.trimLeft();
- }
- return [headers, start];
-}
-
-function parseMultipartForm(request)
-{
- let boundary = null;
- // See if this is a multipart/form-data request, and if so, find the
- // boundary string
- if (request.hasHeader("Content-Type")) {
- var contenttype = request.getHeader("Content-Type");
- var bits = contenttype.split(";");
- if (bits[0] == "multipart/form-data") {
- for (var i = 1; i < bits.length; i++) {
- var b = bits[i].trimLeft();
- if (b.indexOf("boundary=") == 0) {
- // grab everything after boundary=
- boundary = "--" + b.substring(9);
- break;
- }
- }
- }
- }
- if (boundary == null)
- return null;
-
- let body = new BinaryInputStream(request.bodyInputStream);
- let avail;
- let bytes = [];
- while ((avail = body.available()) > 0) {
- let readBytes = body.readByteArray(avail);
- for (let b of readBytes) {
- bytes.push(b);
- }
- }
- let data = "";
- for (let b of bytes) {
- data += String.fromCharCode(b);
- }
- let formData = {};
- let done = false;
- let start = 0;
- while (true) {
- // read first line
- let end = data.indexOf("\r\n", start);
- if (end == -1) {
- done = true;
- end = data.length;
- }
-
- let line = data.substring(start, end);
- // look for closing boundary delimiter line
- if (line == boundary + "--") {
- break;
- }
-
- if (line != boundary) {
- dump("expected boundary line but didn't find it!");
- break;
- }
-
- // parse headers
- start = end + 2;
- let headers = null;
- [headers, start] = parseHeaders(data, start);
-
- // find next boundary string
- end = data.indexOf("\r\n" + boundary, start);
- if (end == -1) {
- dump("couldn't find next boundary string\n");
- break;
- }
-
- // read part data, stick in formData using Content-Disposition header
- let part = data.substring(start, end);
- start = end + 2;
-
- if ("Content-Disposition" in headers) {
- let bits = headers["Content-Disposition"].split(';');
- if (bits[0] == 'form-data') {
- for (let i = 0; i < bits.length; i++) {
- let b = bits[i].trimLeft();
- if (b.indexOf('name=') == 0) {
- //TODO: handle non-ascii here?
- let name = b.substring(6, b.length - 1);
- //TODO: handle multiple-value properties?
- formData[name] = part;
- }
- //TODO: handle filename= ?
- //TODO: handle multipart/mixed for multi-file uploads?
- }
- }
- }
- }
- return formData;
-}
-
-function handleRequest(request, response)
-{
- if (request.method == "GET") {
- let id = null;
- for (let p of request.queryString.split('&')) {
- let [key, value] = p.split('=');
- if (key == 'id')
- id = value;
- }
- if (id == null) {
- response.setStatusLine(request.httpVersion, 400, "Bad Request");
- response.write("Missing id parameter");
- }
- else {
- let data = getState(id);
- if (data == "") {
- response.setStatusLine(request.httpVersion, 404, "Not Found");
- response.write("Not Found");
- }
- else {
- response.setHeader("Content-Type", "text/plain", false);
- response.write(data);
- }
- }
- }
- else if (request.method == "POST") {
- let formData = parseMultipartForm(request);
-
- if (formData && 'upload_file_minidump' in formData) {
- response.setHeader("Content-Type", "text/plain", false);
-
- let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator);
- let uuid = uuidGenerator.generateUUID().toString();
- // ditch the {}, add bp- prefix
- uuid = 'bp-' + uuid.substring(1,uuid.length-2);
-
- let d = JSON.stringify(formData);
- //dump('saving crash report ' + uuid + ': ' + d + '\n');
- setState(uuid, d);
-
- response.write("CrashID=" + uuid + "\n");
- }
- else {
- dump('*** crashreport.sjs: Malformed request?\n');
- response.setStatusLine(request.httpVersion, 400, "Bad Request");
- response.write("Missing minidump file");
- }
- }
- else {
- response.setStatusLine(request.httpVersion, 405, "Method not allowed");
- response.write("Can't handle HTTP method " + request.method);
- }
-}
diff --git a/toolkit/crashreporter/test/browser/head.js b/toolkit/crashreporter/test/browser/head.js
deleted file mode 100644
index f35edfe38..000000000
--- a/toolkit/crashreporter/test/browser/head.js
+++ /dev/null
@@ -1,139 +0,0 @@
-function create_subdir(dir, subdirname) {
- let subdir = dir.clone();
- subdir.append(subdirname);
- if (subdir.exists()) {
- subdir.remove(true);
- }
- subdir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
- return subdir;
-}
-
-// need to hold on to this to unregister for cleanup
-var _provider = null;
-
-function make_fake_appdir() {
- // Create a directory inside the profile and register it as UAppData, so
- // we can stick fake crash reports inside there. We put it inside the profile
- // just because we know that will get cleaned up after the mochitest run.
- let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
- .getService(Ci.nsIProperties);
- let profD = dirSvc.get("ProfD", Ci.nsILocalFile);
- // create a subdir just to keep our files out of the way
- let appD = create_subdir(profD, "UAppData");
-
- let crashesDir = create_subdir(appD, "Crash Reports");
- create_subdir(crashesDir, "pending");
- create_subdir(crashesDir, "submitted");
-
- _provider = {
- getFile: function(prop, persistent) {
- persistent.value = true;
- if (prop == "UAppData") {
- return appD.clone();
- }
- // Depending on timing we can get requests for other files.
- // When we threw an exception here, in the world before bug 997440, this got lost
- // because of the arbitrary JSContext being used in XPCWrappedJSClass::CallMethod.
- // After bug 997440 this gets reported to our window and causes the tests to fail.
- // So, we'll just dump out a message to the logs.
- dump("WARNING: make_fake_appdir - fake nsIDirectoryServiceProvider - Unexpected getFile for: '" + prop + "'\n");
- return null;
- },
- QueryInterface: function(iid) {
- if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
- iid.equals(Ci.nsISupports)) {
- return this;
- }
- throw Components.results.NS_ERROR_NO_INTERFACE;
- }
- };
- // register our new provider
- dirSvc.QueryInterface(Ci.nsIDirectoryService)
- .registerProvider(_provider);
- // and undefine the old value
- try {
- dirSvc.undefine("UAppData");
- } catch (ex) {} // it's ok if this fails, the value might not be cached yet
- return appD.clone();
-}
-
-function cleanup_fake_appdir() {
- let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
- .getService(Ci.nsIProperties);
- dirSvc.QueryInterface(Ci.nsIDirectoryService)
- .unregisterProvider(_provider);
- // undefine our value so future calls get the real value
- try {
- dirSvc.undefine("UAppData");
- } catch (ex) {
- dump("cleanup_fake_appdir: dirSvc.undefine failed: " + ex.message +"\n");
- }
-}
-
-function add_fake_crashes(crD, count) {
- let results = [];
- let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator);
- let submitdir = crD.clone();
- submitdir.append("submitted");
- // create them from oldest to newest, to ensure that about:crashes
- // displays them in the correct order
- let date = Date.now() - count * 60000;
- for (let i = 0; i < count; i++) {
- let uuid = uuidGenerator.generateUUID().toString();
- // ditch the {}
- uuid = "bp-" + uuid.substring(1, uuid.length - 2);
- let fn = uuid + ".txt";
- let file = submitdir.clone();
- file.append(fn);
- file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
- file.lastModifiedTime = date;
- results.push({'id': uuid, 'date': date, 'pending': false});
-
- date += 60000;
- }
- // we want them sorted newest to oldest, since that's the order
- // that about:crashes lists them in
- results.sort((a, b) => b.date - a.date);
- return results;
-}
-
-function writeDataToFile(file, data) {
- var fstream = Cc["@mozilla.org/network/file-output-stream;1"]
- .createInstance(Ci.nsIFileOutputStream);
- // open, write, truncate
- fstream.init(file, -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(data);
- os.close();
- fstream.close();
-}
-
-function addPendingCrashreport(crD, date, extra) {
- let pendingdir = crD.clone();
- pendingdir.append("pending");
- let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator);
- let uuid = uuidGenerator.generateUUID().toString();
- // ditch the {}
- uuid = uuid.substring(1, uuid.length - 1);
- let dumpfile = pendingdir.clone();
- dumpfile.append(uuid + ".dmp");
- writeDataToFile(dumpfile, "MDMP"); // that's the start of a valid minidump, anyway
- let extrafile = pendingdir.clone();
- extrafile.append(uuid + ".extra");
- let extradata = "";
- for (let x in extra) {
- extradata += x + "=" + extra[x] + "\n";
- }
- writeDataToFile(extrafile, extradata);
- let memoryfile = pendingdir.clone();
- memoryfile.append(uuid + ".memory.json.gz");
- writeDataToFile(memoryfile, "Let's pretend this is a memory report");
- dumpfile.lastModifiedTime = date;
- extrafile.lastModifiedTime = date;
- memoryfile.lastModifiedTime = date;
- return {'id': uuid, 'date': date, 'pending': true, 'extra': extra};
-}