commit 20fd5dd2992361ed64b80319f1aa5cd91ef78a9e
parent c3dcaf9fe03d3d76fefbb53e0aadd314808e2caf
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 8 Oct 2016 20:24:39 -0400
Include installed extensions with Debug ID
Previously only with Report ID
Diffstat:
6 files changed, 82 insertions(+), 87 deletions(-)
diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml
@@ -615,7 +615,7 @@
&& (!SJOW._zoteroMatchTo || SJOW._zoteroMatchTo !== matchTo)) return;
if (!SJOW.tinyMCE) {
- var exts = Zotero.getInstalledExtensions(function(exts) {
+ Zotero.getInstalledExtensions().then(function(exts) {
for (let ext of exts) {
if (ext.indexOf('NoScript') != -1 && ext.indexOf('disabled') == -1) {
var doc = win.document;
diff --git a/chrome/content/zotero/errorReport.xul b/chrome/content/zotero/errorReport.xul
@@ -14,9 +14,6 @@
Components.utils.import("resource://zotero/config.js");
var Zotero_Error_Report = new function() {
- this.init = init;
- this.sendErrorReport = sendErrorReport;
-
var obj = window.arguments[0].wrappedJSObject;
var Zotero = obj.Zotero;
var data = obj.data;
@@ -26,40 +23,37 @@
var diagnosticInfo = false;
- function init() {
+ this.init = Zotero.Promise.coroutine(function* () {
var wizard = document.getElementById('zotero-error-report');
var continueButton = wizard.getButton('next');
continueButton.disabled = true;
- Zotero.getSystemInfo(function(info) {
- var errorDataText = errorData.length
- ? data.errorData.join('\n\n')
- : Zotero.getString('errorReport.noErrorsLogged', Zotero.appName);
-
- diagnosticInfo = info;
-
- var logText = errorDataText + '\n\n'
- + (extraData !== '' ? extraData + '\n\n' : '')
- + diagnosticInfo;
-
- if (document.getElementById('zotero-failure-message').hasChildNodes()) {
- var textNode = document.getElementById('zotero-failure-message').firstChild;
- document.getElementById('zotero-failure-message').removeChild(textNode);
- }
-
- document.getElementById('zotero-failure-message').appendChild(document.createTextNode(msg));
- document.getElementById('zotero-error-message').value = logText;
-
- continueButton.disabled = false;
- continueButton.focus();
- var str = Zotero.getString(
- 'errorReport.advanceMessage', continueButton.getAttribute('label')
- );
- document.getElementById('zotero-advance-message').setAttribute('value', str);
- });
- }
+ var diagnosticInfo = yield Zotero.getSystemInfo();
+ var errorDataText = errorData.length
+ ? data.errorData.join('\n\n')
+ : Zotero.getString('errorReport.noErrorsLogged', Zotero.appName);
+
+ var logText = errorDataText + '\n\n'
+ + (extraData !== '' ? extraData + '\n\n' : '')
+ + diagnosticInfo;
+
+ if (document.getElementById('zotero-failure-message').hasChildNodes()) {
+ var textNode = document.getElementById('zotero-failure-message').firstChild;
+ document.getElementById('zotero-failure-message').removeChild(textNode);
+ }
+
+ document.getElementById('zotero-failure-message').appendChild(document.createTextNode(msg));
+ document.getElementById('zotero-error-message').value = logText;
+
+ continueButton.disabled = false;
+ continueButton.focus();
+ var str = Zotero.getString(
+ 'errorReport.advanceMessage', continueButton.getAttribute('label')
+ );
+ document.getElementById('zotero-advance-message').setAttribute('value', str);
+ });
- function sendErrorReport() {
+ this.sendErrorReport = Zotero.Promise.coroutine(function* () {
var wizard = document.getElementById('zotero-error-report');
var continueButton = wizard.getButton('next');
continueButton.disabled = true;
@@ -76,12 +70,17 @@
body += key + '=' + encodeURIComponent(parts[key]) + '&';
}
body = body.substr(0, body.length - 1);
- var url = ZOTERO_CONFIG.REPOSITORY_URL + "report";
- Zotero.HTTP.promise('POST', url,
- { body: body, successCodes: false, foreground: true })
- .then(_sendErrorReportCallback)
- .done();
- }
+ var req = yield Zotero.HTTP.request(
+ "POST",
+ ZOTERO_CONFIG.REPOSITORY_URL + "report",
+ {
+ body,
+ successCodes: false,
+ foreground: true
+ }
+ );
+ _sendErrorReportCallback(req);
+ });
function _sendErrorReportCallback(xmlhttp) {
diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js
@@ -618,7 +618,7 @@ Zotero_Preferences.Debug_Output = {
Components.utils.import("resource://zotero/config.js");
var url = ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1";
- var output = Zotero.Debug.get(
+ var output = yield Zotero.Debug.get(
Zotero.Prefs.get('debug.store.submitSize'),
Zotero.Prefs.get('debug.store.submitLineLength')
);
diff --git a/chrome/content/zotero/xpcom/connector/connector.js b/chrome/content/zotero/xpcom/connector/connector.js
@@ -276,9 +276,9 @@ Zotero.Connector_Debug = new function() {
/**
* Call a callback with the lines themselves
*/
- this.get = function(callback) {
- callback(Zotero.Debug.get());
- }
+ this.get = Zotero.Promise.coroutine(function* (callback) {
+ callback(yield Zotero.Debug.get());
+ });
/**
* Call a callback with the number of lines of output
@@ -288,23 +288,31 @@ Zotero.Connector_Debug = new function() {
}
/**
- * Submit data to the sserver
+ * Submit data to the server
*/
- this.submitReport = function(callback) {
- Zotero.HTTP.doPost(ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1", Zotero.Debug.get(),
- function(xmlhttp) {
- if (!xmlhttp.responseXML) {
- callback(false, 'Invalid response from server');
- return;
- }
- var reported = xmlhttp.responseXML.getElementsByTagName('reported');
- if (reported.length != 1) {
- callback(false, 'The server returned an error. Please try again.');
- return;
- }
-
- var reportID = reported[0].getAttribute('reportID');
- callback(true, reportID);
- }, {"Content-Type":"text/plain"});
- }
+ this.submitReport = Zotero.Promise.coroutine(function* (callback) {
+ var output = yield Zotero.Debug.get();
+ var req = yield Zotero.HTTP.request(
+ ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1",
+ {
+ headers: {
+ "Content-Type": "text/plain"
+ },
+ body: output,
+ successCodes: false
+ }
+ );
+ if (!xmlhttp.responseXML) {
+ callback(false, 'Invalid response from server');
+ return;
+ }
+ var reported = xmlhttp.responseXML.getElementsByTagName('reported');
+ if (reported.length != 1) {
+ callback(false, 'The server returned an error. Please try again.');
+ return;
+ }
+
+ var reportID = reported[0].getAttribute('reportID');
+ callback(true, reportID);
+ });
}
diff --git a/chrome/content/zotero/xpcom/debug.js b/chrome/content/zotero/xpcom/debug.js
@@ -129,7 +129,7 @@ Zotero.Debug = new function () {
}
- this.get = function (maxChars, maxLineLength) {
+ this.get = Zotero.Promise.coroutine(function* (maxChars, maxLineLength) {
var output = _output;
var total = output.length;
@@ -160,13 +160,13 @@ Zotero.Debug = new function () {
if(Zotero.getErrors) {
return Zotero.getErrors(true).join('\n\n') +
- "\n\n" + Zotero.getSystemInfo() + "\n\n" +
+ "\n\n" + (yield Zotero.getSystemInfo()) + "\n\n" +
"=========================================================\n\n" +
output;
} else {
return output;
}
- }
+ });
this.setStore = function (enable) {
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -44,7 +44,6 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
this.log = log;
this.logError = logError;
this.getErrors = getErrors;
- this.getSystemInfo = getSystemInfo;
this.getString = getString;
this.localeJoin = localeJoin;
this.setFontSize = setFontSize;
@@ -1453,11 +1452,8 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
/**
* Get versions, platform, etc.
- *
- * Can be used synchronously or asynchronously; info on other add-ons
- * is available only in async mode
*/
- function getSystemInfo(callback) {
+ this.getSystemInfo = Zotero.Promise.coroutine(function* () {
var info = {
version: Zotero.version,
platform: Zotero.platform,
@@ -1467,18 +1463,8 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
appVersion: Services.appinfo.version
};
- if (callback) {
- Zotero.getInstalledExtensions(function(extensions) {
- info.extensions = extensions.join(', ');
-
- var str = '';
- for (var key in info) {
- str += key + ' => ' + info[key] + ', ';
- }
- str = str.substr(0, str.length - 2);
- callback(str);
- });
- }
+ var extensions = yield Zotero.getInstalledExtensions();
+ info.extensions = extensions.join(', ');
var str = '';
for (var key in info) {
@@ -1486,20 +1472,21 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
}
str = str.substr(0, str.length - 2);
return str;
- }
+ });
/**
- * @return {String[]} Array of extension names and versions
+ * @return {Promise<String[]>} - Promise for an array of extension names and versions
*/
- this.getInstalledExtensions = function(callback) {
+ this.getInstalledExtensions = Zotero.Promise.method(function () {
+ var deferred = Zotero.Promise.defer();
function onHaveInstalledAddons(installed) {
installed.sort(function(a, b) {
return ((a.appDisabled || a.userDisabled) ? 1 : 0) -
((b.appDisabled || b.userDisabled) ? 1 : 0);
});
var addons = [];
- for each(var addon in installed) {
+ for (let addon of installed) {
switch (addon.id) {
case "zotero@chnm.gmu.edu":
case "{972ce4c6-7e08-4474-a285-3208198ce6fd}": // Default theme
@@ -1511,12 +1498,13 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
+ ((addon.appDisabled || addon.userDisabled) ? ", disabled" : "")
+ ")");
}
- callback(addons);
+ deferred.resolve(addons);
}
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAllAddons(onHaveInstalledAddons);
- }
+ return deferred.promise;
+ });
function getString(name, params){
try {