Compare commits

...

16 Commits
master ... fx60

Author SHA1 Message Date
Dan Stillman
a19ca7da07 Update Travis to 59.0b11 unbranded build 2018-02-25 22:20:40 -05:00
Dan Stillman
77a6af9e5b Fx60 compatibility: Fix snapshot filenames
nsIURL doesn't seem to work anymore, so add Zotero.Utilities.parseURL(),
which uses the `url` package from NPM and adds fileName, fileExtension,
and fileBaseName.
2018-02-25 22:17:28 -05:00
Dan Stillman
ea77b407a3 Fx60 compatibility: Fix "path is undefined" in cookie sandbox
getCookiesForURI() seems to now get an nsIURL that won't query to
nsIURI, so look for `filePath` in addition to `path`.
2018-02-25 22:17:28 -05:00
Dan Stillman
6d491b1956 Fx60 compatibility: Switch to new XMLHttpRequest() 2018-02-25 22:17:27 -05:00
Dan Stillman
3e5952f575 Fx60 compatibility: Add built_in_addons.json file
fetch_xulrunner.sh updates the built-in path to point to this file, but
it's not currently being read properly for some reason (and I'm not sure
it does anything we need).
2018-02-25 22:17:27 -05:00
Dan Stillman
76bf7a6f61 Fx60 compatibility: Fix devtools initialization 2018-02-25 22:17:26 -05:00
Dan Stillman
4a22184156 Use Services for an nsILoginManager initialization 2018-02-25 22:17:26 -05:00
Dan Stillman
95bb107867 Fx60 compatibility: Fix access to translator object in sandbox
There's almost certainly other sandbox breakage
2018-02-25 22:17:25 -05:00
Dan Stillman
676799271e Fx60 compatibility: Update old-style shorthand function definitions 2018-02-25 22:17:24 -05:00
Dan Stillman
b835970ead Fx60 compatibility: += operator no longer works on nsIURI spec 2018-02-25 22:17:24 -05:00
Dan Stillman
d340b3c85b Fx60 compatibility: nsILocalFile -> nsIFile 2018-02-25 22:17:23 -05:00
Dan Stillman
c1f195ebeb Fx60 compatibility: Update pref handling
- getStringPref/setStringPref are now used for strings instead of
  getComplexValue/setComplexValue
- Remove nsIPrefBranch2 reference
- If there was a pref failure during initialization, nothing was logged
  to the terminal
2018-02-25 22:17:23 -05:00
Dan Stillman
b7b9a2063b Fx60 compatibility: Don't try to override toString() on an object 2018-02-25 22:17:22 -05:00
Dan Stillman
b2fd9fece7 Fx60 compatibility: Update nsIInputStreamPump init() calls 2018-02-25 22:17:22 -05:00
Dan Stillman
c2b77890c3 Fx60 compatibility: Fix issues with JS code modules
- The Mozilla CommonJS loader is no longer available, so bundle the
  Fx52 version of it
- Strict mode is enforced
- `this` is only defined as a global object in .jsm files, not .js files
- `this` can't be converted to a string for BackstagePass test, so check
  for presence of Components.utils.import instead
- The return value from import() is no longer available
2018-02-25 22:17:21 -05:00
Dan Stillman
1d4a97c220 Fx60 compatibility: Remove versioned JavaScript 2018-02-25 22:17:21 -05:00
47 changed files with 1365 additions and 136 deletions

View File

@ -10,7 +10,7 @@ env:
global:
secure: "NxvkbZ7/Op7BTGQRR3C4q8lLoO29f8WtyNN27NSH7AO3H0vBr1Vp5xO8gn+H2qHEug5HvM+YrZ/xAkNXaZVbOInmBmKVMxqVvdpKp9JM1Amf+gzsXWQphfySvs6iqzyP6cwU/jspdvX/WSakgU5v7PWXxtUIaKxdANt6Rw7W+Pc="
matrix:
- FX_VERSION="52.0.3"
- FX_VERSION="59.0b11"
matrix:
fast_finish: true
#allow_failures:
@ -22,8 +22,8 @@ addons:
packages:
- dbus-x11
install:
- if [ $FX_VERSION = "52.0.3" ]; then
wget -O tarball "https://archive.mozilla.org/pub/firefox/tinderbox-builds/mozilla-release-linux64-add-on-devel/1491732920/firefox-52.0.3.en-US.linux-x86_64-add-on-devel.tar.bz2";
- if [ $FX_VERSION = "59.0b11" ]; then
wget -O tarball "https://queue.taskcluster.net/v1/task/L9FO6qp_TnaLkGB_fFy0Sw/runs/0/artifacts/public/build/target.tar.bz2";
fi
- tar xf tarball
before_script:

View File

@ -1157,7 +1157,7 @@
if (this.eventHandlers['itemtypechange'] && this.eventHandlers['itemtypechange'].length) {
var self = this;
this.eventHandlers['itemtypechange'].forEach(function (f) f.bind(self)());
this.eventHandlers['itemtypechange'].forEach(f => f.bind(self)());
}
return true;

View File

@ -652,14 +652,11 @@
// for read-only mode
var htmlFile = this.mode + (this.getAttribute('readonly') != 'true' ? "" : "view");
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var uri = ios.newURI("resource://zotero/tinymce/" + htmlFile + ".html", null, null);
var url = `resource://zotero/tinymce/${htmlFile}.html`
// Pass directionality (LTR/RTL) and locale in URL
uri.spec += "?locale=" + encodeURIComponent(Zotero.locale)
+ "?locale=" + encodeURIComponent(Zotero.locale)
+ "&dir=" + Zotero.dir;
var uri = Services.io.newURI(url, null, null);
Zotero.debug("Loading " + uri.spec);

View File

@ -139,7 +139,7 @@
<body><![CDATA[
return Zotero.spawn(function* () {
if (type == 'setting') {
if (ids.some(function (val) val.split("/")[1] == 'tagColors') && this.item) {
if (ids.some(val => val.split("/")[1] == 'tagColors') && this.item) {
this.reload();
return;
}
@ -227,7 +227,7 @@
// Sort tags alphabetically
var collation = Zotero.getLocaleCollation();
tags.sort(function (a, b) collation.compareString(1, a.tag, b.tag));
tags.sort((a, b) => collation.compareString(1, a.tag, b.tag));
for (let i=0; i<tags.length; i++) {
this.addDynamicRow(tags[i], i+1);
@ -682,7 +682,7 @@
return;
}
var tags = value.split(/\r\n?|\n/).map(function (val) val.trim());
var tags = value.split(/\r\n?|\n/).map(val => val.trim());
// Modifying existing tag with a single new one
if (!isNew && tags.length < 2) {

View File

@ -0,0 +1 @@
{"system": ["activity-stream@mozilla.org", "aushelper@mozilla.org", "firefox@getpocket.com", "followonsearch@mozilla.com", "formautofill@mozilla.org", "onboarding@mozilla.org", "screenshots@mozilla.org", "shield-recipe-client@mozilla.org", "webcompat@mozilla.org"]}

View File

@ -7,4 +7,4 @@ var Zotero = Components.classes['@zotero.org/Zotero;1']
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
Components.utils.import('resource://zotero/require.js');
Components.utils.import('resource://zotero/require.jsm');

View File

@ -41,8 +41,8 @@
onunload="Zotero_QuickFormat.onUnload()">
<script src="../include.js"/>
<script src="windowDraggingUtils.js" type="text/javascript;version=1.8"/>
<script src="quickFormat.js" type="text/javascript;version=1.8"/>
<script src="windowDraggingUtils.js" type="text/javascript"/>
<script src="quickFormat.js" type="text/javascript"/>
<box orient="horizontal" id="quick-format-entry">
<deck id="quick-format-deck" selectedIndex="0" flex="1">

View File

@ -30,7 +30,7 @@
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="include.js"/>
<script src="itemPane.js" type="application/javascript;version=1.8"/>
<script src="itemPane.js" type="application/javascript"/>
<vbox id="zotero-item-pane" zotero-persist="width height">
<!-- My Publications -->

View File

@ -83,5 +83,5 @@
observerService.notifyObservers(null, "charsetmenu-selected", "other");
]]>
</script>
<script src="preferences.js" type="application/javascript;version=1.8"/>
<script src="preferences.js" type="application/javascript"/>
</prefwindow>

View File

@ -329,5 +329,5 @@
<separator/>
</prefpane>
<script src="preferences_advanced.js" type="application/javascript;version=1.8"/>
<script src="preferences_advanced.js" type="application/javascript"/>
</overlay>

View File

@ -110,5 +110,5 @@
</tabbox>
</prefpane>
<script src="preferences_cite.js" type="application/javascript;version=1.8"/>
<script src="preferences_cite.js" type="application/javascript"/>
</overlay>

View File

@ -111,6 +111,6 @@
<separator/>
<separator/>
<script src="preferences_export.js" type="application/javascript;version=1.8"/>
<script src="preferences_export.js" type="application/javascript"/>
</prefpane>
</overlay>

View File

@ -90,6 +90,6 @@
<separator/>
</prefpane>
<script src="preferences_proxies.js" type="application/javascript;version=1.8"/>
<script src="preferences_proxies.js" type="application/javascript"/>
</prefwindow>
</overlay>

View File

@ -146,5 +146,5 @@
<separator/>
</prefpane>
<script src="preferences_general.js" type="application/javascript;version=1.8"/>
<script src="preferences_general.js" type="application/javascript"/>
</overlay>

View File

@ -85,5 +85,5 @@
<separator/>
</prefpane>
<script src="preferences_search.js" type="application/javascript;version=1.8"/>
<script src="preferences_search.js" type="application/javascript"/>
</overlay>

View File

@ -326,5 +326,5 @@
<separator/>
</prefpane>
<script src="preferences_sync.js" type="application/javascript;version=1.8"/>
<script src="preferences_sync.js" type="application/javascript"/>
</overlay>

View File

@ -11,7 +11,7 @@
style="padding:2em">
<script src="../include.js"/>
<script type="application/javascript;version=1.8" src="test.js"/>
<script type="application/javascript" src="test.js"/>
<hbox><label>This is a test page.</label></hbox>
</window>

View File

@ -1131,53 +1131,43 @@ Zotero.Attachments = new function(){
function _getFileNameFromURL(url, contentType){
var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURL);
nsIURL.spec = url;
url = Zotero.Utilities.parseURL(url);
var ext = Zotero.MIME.getPrimaryExtension(contentType, nsIURL.fileExtension);
var fileBaseName = url.fileBaseName;
var fileExt = Zotero.MIME.getPrimaryExtension(contentType, url.fileExtension);
if (!nsIURL.fileName) {
var matches = nsIURL.directory.match(/\/([^\/]+)\/$/);
if (!fileBaseName) {
let matches = url.pathname.match(/\/([^\/]+)\/$/);
// If no filename, use the last part of the path if there is one
if (matches) {
nsIURL.fileName = matches[1];
fileBaseName = matches[1];
}
// Or just use the host
else {
nsIURL.fileName = nsIURL.host;
var tld = nsIURL.fileExtension;
fileBaseName = url.hostname;
}
}
// If we found a better extension, use that
if (ext && (!nsIURL.fileExtension || nsIURL.fileExtension != ext)) {
nsIURL.fileExtension = ext;
}
// If we replaced the TLD (which would've been interpreted as the extension), add it back
if (tld && tld != nsIURL.fileExtension) {
nsIURL.fileBaseName = nsIURL.fileBaseName + '.' + tld;
}
// Test unencoding fileBaseName
try {
decodeURIComponent(nsIURL.fileBaseName);
decodeURIComponent(fileBaseName);
}
catch (e) {
if (e.name == 'URIError') {
// If we got a 'malformed URI sequence' while decoding,
// use MD5 of fileBaseName
nsIURL.fileBaseName = Zotero.Utilities.Internal.md5(nsIURL.fileBaseName, false);
fileBaseName = Zotero.Utilities.Internal.md5(fileBaseName, false);
}
else {
throw e;
}
}
var fileName = fileBaseName + (fileExt ? '.' + fileExt : '');
// Pass unencoded name to getValidFileName() so that percent-encoded
// characters aren't stripped to just numbers
return Zotero.File.getValidFileName(decodeURIComponent(nsIURL.fileName));
return Zotero.File.getValidFileName(decodeURIComponent(fileName));
}

View File

@ -221,7 +221,7 @@ Zotero.CookieSandbox.prototype = {
*/
"getCookiesForURI": function(uri) {
var hostParts = Zotero.CookieSandbox.normalizeHost(uri.host).split('.'),
pathParts = Zotero.CookieSandbox.normalizePath(uri.path).split('/'),
pathParts = Zotero.CookieSandbox.normalizePath(uri.filePath || uri.path).split('/'),
cookies = {}, found = false, secure = uri.scheme.toUpperCase() == 'HTTPS';
// Fetch cookies starting from the highest level domain

View File

@ -332,8 +332,7 @@ Zotero.File = new function(){
* Runs synchronously, so should only be run on local (e.g. chrome) URLs
*/
function getContentsFromURL(url) {
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', url, false);
xmlhttp.overrideMimeType("text/plain");
xmlhttp.send(null);

View File

@ -158,8 +158,7 @@ Zotero.HTTP = new function() {
var deferred = Zotero.Promise.defer();
if (!this.mock) {
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
}
else {
var xmlhttp = new this.mock;
@ -367,8 +366,7 @@ Zotero.HTTP = new function() {
return false;
}
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
@ -441,8 +439,7 @@ Zotero.HTTP = new function() {
return false;
}
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('POST', url, true);
@ -519,8 +516,7 @@ Zotero.HTTP = new function() {
// Workaround for "Accept third-party cookies" being off in Firefox 3.0.1
// https://www.zotero.org/trac/ticket/1070
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('HEAD', url, true);
@ -567,8 +563,7 @@ Zotero.HTTP = new function() {
return false;
}
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('OPTIONS', uri.spec, true);
@ -737,8 +732,7 @@ Zotero.HTTP = new function() {
return false;
}
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('MKCOL', uri.spec, true);
@ -769,8 +763,7 @@ Zotero.HTTP = new function() {
return false;
}
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open("DELETE", uri.spec, true);

View File

@ -77,9 +77,7 @@ Zotero.Integration = new function() {
// on OS X, first try /Users/Shared for those who can't put pipes in their home
// directories
var pipe = null;
var sharedDir = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
sharedDir.initWithPath("/Users/Shared");
var sharedDir = Zotero.File.pathToFile('/Users/Shared');
if(sharedDir.exists() && sharedDir.isDirectory()) {
var logname = Components.classes["@mozilla.org/process/environment;1"].

View File

@ -229,7 +229,7 @@ Zotero.IPC = new function() {
if(pipeDir.exists()) {
var dirEntries = pipeDir.directoryEntries;
while (dirEntries.hasMoreElements()) {
var pipe = dirEntries.getNext().QueryInterface(Ci.nsILocalFile);
var pipe = dirEntries.getNext().QueryInterface(Ci.nsIFile);
if(pipe.leafName[0] !== "." && (!_instancePipe || !pipe.equals(_instancePipe))) {
pipes.push(pipe);
}
@ -461,7 +461,12 @@ Zotero.IPC.Pipe.DeferredOpen.prototype = {
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].
createInstance(Components.interfaces.nsIInputStreamPump);
try {
pump.init(fifoStream, 0, 0, true);
}
catch (e) {
pump.init(fifoStream, -1, -1, 4096, 1, true);
}
pump.asyncRead(this, null);
this._openTime = Date.now();

View File

@ -47,7 +47,7 @@ Zotero.OpenURL = new function() {
* Queries OCLC's OpenURL resolver registry and returns an address and version
*/
function discoverResolvers() {
var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
var req = new XMLHttpRequest();
req.open("GET", "http://worldcatlibraries.org/registry/lookup?IP=requestor", false);
req.send(null);

View File

@ -1,4 +1,4 @@
Components.utils.import("resource://zotero/pathparser.js", Zotero);
Components.utils.import("resource://zotero/pathparser.jsm", Zotero);
Zotero.Router = Zotero.PathParser;
delete Zotero.PathParser;

View File

@ -136,7 +136,12 @@ Zotero.Server.SocketListener = new function() {
var dataListener = new Zotero.Server.DataListener(iStream, oStream);
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]
.createInstance(Components.interfaces.nsIInputStreamPump);
try {
pump.init(iStream, 0, 0, false);
}
catch (e) {
pump.init(iStream, -1, -1, 0, 0, false);
}
pump.asyncRead(dataListener, null);
}

View File

@ -38,10 +38,10 @@ Zotero.Sync.Storage.Result.prototype.updateFromResults = function (results) {
}
Zotero.Sync.Storage.Result.prototype.toString = function () {
/*Zotero.Sync.Storage.Result.prototype.toString = function () {
var obj = {};
for (let prop of this._props) {
obj[prop] = this[prop] || false;
}
return JSON.stringify(obj, null, " ");
}
}*/

View File

@ -381,9 +381,7 @@ Zotero.Sync.Data.Local = {
*/
_getAPIKeyLoginInfo: function () {
try {
var loginManager = Components.classes["@mozilla.org/login-manager;1"]
.getService(Components.interfaces.nsILoginManager);
var logins = loginManager.findLogins(
var logins = Services.logins.findLogins(
{},
this._loginManagerHost,
null,

View File

@ -331,16 +331,6 @@ Zotero.Translate.Sandbox = {
* @inner
*/
var safeTranslator = {};
safeTranslator.__exposedProps__ = {
"setSearch":"r",
"setDocument":"r",
"setHandler":"r",
"setString":"r",
"setTranslator":"r",
"getTranslators":"r",
"translate":"r",
"getTranslatorObject":"r"
};
safeTranslator.setSearch = function(arg) {
if(!Zotero.isBookmarklet) arg = JSON.parse(JSON.stringify(arg));
return translation.setSearch(arg);
@ -480,11 +470,10 @@ Zotero.Translate.Sandbox = {
if (Zotero.isFx) {
for(var i in safeTranslator) {
if (typeof(safeTranslator[i]) === "function") {
safeTranslator[i] = translate._sandboxManager._makeContentForwarder(function(func) {
return function() {
func.apply(safeTranslator, this.args.wrappedJSObject || this.args);
}
}(safeTranslator[i]));
safeTranslator[i] = Components.utils.exportFunction(
safeTranslator[i],
translate._sandboxManager.sandbox
)
}
}
}

View File

@ -1861,6 +1861,21 @@ Zotero.Utilities = {
}
},
parseURL: function (url) {
var parts = require('url').parse(url);
// fileName
parts.fileName = parts.pathname.split('/').pop();
// fileExtension
var pos = parts.fileName.lastIndexOf('.');
parts.fileExtension = pos == -1 ? '' : parts.fileName.substr(pos + 1);
// fileBaseName
parts.fileBaseName = parts.fileName
// filename up to the period before the file extension, if there is one
.substr(0, parts.fileName.length - (parts.fileExtension ? parts.fileExtension.length + 1 : 0));
return parts;
},
/**
* Get the real target URL from an intermediate URL
*/

View File

@ -254,7 +254,12 @@ Zotero.Utilities.Internal = {
// Send input stream to stream converter
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]
.createInstance(Components.interfaces.nsIInputStreamPump);
try {
pump.init(is, 0, 0, true);
}
catch (e) {
pump.init(is, -1, -1, 0, 0, true);
}
pump.asyncRead(converter, null);
return deferred.promise;
@ -314,7 +319,12 @@ Zotero.Utilities.Internal = {
// Send input stream to stream converter
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]
.createInstance(Components.interfaces.nsIInputStreamPump);
try {
pump.init(bis, 0, 0, true);
}
catch (e) {
pump.init(bis, -1, -1, 0, 0, true);
}
pump.asyncRead(converter, null);
return deferred.promise;

View File

@ -24,6 +24,7 @@
*/
// Commonly used imports accessible anywhere
Components.utils.importGlobalProperties(["XMLHttpRequest"]);
Components.utils.import("resource://zotero/config.js");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
@ -267,8 +268,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
// Set the locale direction to Zotero.dir
// DEBUG: is there a better way to get the entity from JS?
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'chrome://global/locale/global.dtd', false);
xmlhttp.overrideMimeType('text/plain');
xmlhttp.send(null);
@ -2242,13 +2242,22 @@ Zotero.Prefs = new function(){
case branch.PREF_BOOL:
return branch.getBoolPref(pref);
case branch.PREF_STRING:
// Pre-Fx59
if (!branch.getStringPref) {
return '' + branch.getComplexValue(pref, Components.interfaces.nsISupportsString);
}
return branch.getStringPref(pref);
case branch.PREF_INT:
return branch.getIntPref(pref);
}
}
catch (e) {
throw ("Invalid preference '" + pref + "'");
// If debug system isn't yet initialized, log proper error
if (Zotero.Debug.enabled === undefined) {
dump(e + "\n\n");
}
Zotero.logError(e);
throw new Error(`Error getting preference '${pref}'`);
}
}
@ -2269,10 +2278,14 @@ Zotero.Prefs = new function(){
case branch.PREF_BOOL:
return branch.setBoolPref(pref, value);
case branch.PREF_STRING:
// Pre-Fx59
if (!branch.setStringPref) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = value;
return branch.setComplexValue(pref, Ci.nsISupportsString, str);
}
return branch.setStringPref(pref, value);
case branch.PREF_INT:
return branch.setIntPref(pref, value);
@ -2284,7 +2297,14 @@ Zotero.Prefs = new function(){
}
if (typeof value == 'string') {
Zotero.debug("Creating string pref '" + pref + "'");
return branch.setCharPref(pref, value);
// Pre-Fx59
if (!branch.setStringPref) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = value;
return branch.setComplexValue(pref, Ci.nsISupportsString, str);
}
return branch.setStringPref(pref, value);
}
if (parseInt(value) == value) {
Zotero.debug("Creating integer pref '" + pref + "'");
@ -2294,8 +2314,12 @@ Zotero.Prefs = new function(){
}
}
catch (e) {
// If debug system isn't yet initialized, log proper error
if (Zotero.Debug.enabled === undefined) {
dump(e + "\n\n");
}
Zotero.logError(e);
throw new Error("Invalid preference '" + pref + "'");
throw new Error(`Error setting preference '${pref}'`);
}
}
@ -2414,7 +2438,6 @@ Zotero.Prefs = new function(){
// Methods to register a preferences observer
//
function register(){
this.prefBranch.QueryInterface(Components.interfaces.nsIPrefBranch2);
this.prefBranch.addObserver("", this, false);
// Register pre-set handlers

View File

@ -38,14 +38,14 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="include.js"/>
<script src="zoteroPane.js" type="application/javascript;version=1.8"/>
<script src="zoteroPane.js" type="application/javascript"/>
<script src="fileInterface.js"/>
<script src="reportInterface.js"/>
<script src="timelineInterface.js"/>
<script src="recognizePDFDialog.js"/>
<script src="browser.js" type="application/javascript;version=1.8"/>
<script src="browser.js" type="application/javascript"/>
<script src="lookup.js"/>
<script src="locateMenu.js" type="application/javascript;version=1.8"/>
<script src="locateMenu.js" type="application/javascript"/>
<commandset id="mainCommandSet">
<command id="cmd_zotero_reportErrors" oncommand="ZoteroPane_Local.reportErrors();"/>

View File

@ -1221,7 +1221,12 @@ AsyncChannel.prototype = {
//Zotero.debug("AsyncChannel: Got input stream from generator");
var pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(Ci.nsIInputStreamPump);
try {
pump.init(data, 0, 0, true);
}
catch (e) {
pump.init(data, -1, -1, 0, 0, true);
}
pump.asyncRead(listenerWrapper, context);
}
else if (data instanceof Ci.nsIFile || data instanceof Ci.nsIURI) {

View File

@ -154,9 +154,9 @@ var isFirstLoadThisSession = true;
var zContext = null;
var initCallbacks = [];
var zInitOptions = {};
Components.utils.import('resource://zotero/require.js');
Components.utils.import('resource://zotero/require.jsm');
ZoteroContext = function() {}
var ZoteroContext = function() {}
ZoteroContext.prototype = {
require,
@ -585,8 +585,8 @@ ZoteroCommandLineHandler.prototype = {
if (!DebuggerServer.initialized) {
dump("Initializing devtools server\n");
DebuggerServer.init();
DebuggerServer.registerAllActors();
DebuggerServer.allowChromeProcess = true;
DebuggerServer.addBrowserActors();
}
let listener = DebuggerServer.createListener();

7
package-lock.json generated
View File

@ -3637,8 +3637,7 @@
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
"dev": true
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
},
"querystring-es3": {
"version": "0.2.1",
@ -4553,7 +4552,6 @@
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz",
"integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=",
"dev": true,
"requires": {
"punycode": "1.3.2",
"querystring": "0.2.0"
@ -4562,8 +4560,7 @@
"punycode": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
"integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=",
"dev": true
"integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
}
}
},

View File

@ -18,6 +18,7 @@
"bluebird": "^3.5.1",
"react": "^15.6.2",
"react-dom": "^15.6.2",
"url": "^0.11.0",
"zotero-web-library": "^0.9.4-alpha"
},
"devDependencies": {

View File

@ -23,8 +23,8 @@
***** END LICENSE BLOCK *****
*/
EXPORTED_SYMBOLS = ["ConcurrentCaller"];
Components.utils.import('resource://zotero/require.js');
var EXPORTED_SYMBOLS = ["ConcurrentCaller"];
Components.utils.import('resource://zotero/require.jsm');
var Promise = require('resource://zotero/bluebird.js');
@ -58,7 +58,7 @@ var Promise = require('resource://zotero/bluebird.js');
* beginning of another, in milliseconds
* @param {Function} [options.logger]
*/
ConcurrentCaller = function (options = {}) {
var ConcurrentCaller = function (options = {}) {
if (typeof options == 'number') {
this._log("ConcurrentCaller now takes an object rather than a number");
options = {

View File

@ -1,3 +1,5 @@
var EXPORTED_SYMBOLS = ["ZOTERO_CONFIG"];
var ZOTERO_CONFIG = {
GUID: 'zotero@chnm.gmu.edu',
ID: 'zotero', // used for db filename, etc.
@ -25,5 +27,3 @@ var ZOTERO_CONFIG = {
FEEDBACK_URL: "https://forums.zotero.org/",
CONNECTORS_URL: "https://www.zotero.org/download/connectors"
};
EXPORTED_SYMBOLS = ["ZOTERO_CONFIG"];

1148
resource/loader.jsm Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
* License: MIT
* https://github.com/dstillman/pathparser.js
*/
(function (factory) {
(function (root, factory) {
// AMD/RequireJS
if (typeof define === 'function' && define.amd) {
define(factory);
@ -13,14 +13,16 @@
} else if (typeof exports === 'object') {
module.exports = factory();
// Mozilla JSM
} else if (~String(this).indexOf('BackstagePass')) {
EXPORTED_SYMBOLS = ["PathParser"];
PathParser = factory();
} else if (typeof Components != 'undefined'
&& typeof Components.utils != 'undefined'
&& typeof Components.utils.import == 'function') {
root.EXPORTED_SYMBOLS = ["PathParser"];
root.PathParser = factory();
// Browser global
} else {
PathParser = factory();
root.PathParser = factory();
}
}(function () {
}(this, function () {
"use strict";
var PathParser = function (params) {

View File

@ -3,7 +3,7 @@
var EXPORTED_SYMBOLS = ['require'];
var require = (function() {
var { Loader, Require, Module } = Components.utils.import('resource://gre/modules/commonjs/toolkit/loader.js');
Components.utils.import('resource://zotero/loader.jsm');
var requirer = Module('/', '/');
var _runningTimers = {};
var window = {};

View File

@ -27,7 +27,7 @@
* installable and available in the cite preferences pane.
*/
EXPORTED_SYMBOLS = ["ZoteroPluginInstaller"];
var EXPORTED_SYMBOLS = ["ZoteroPluginInstaller"];
var Zotero = Components.classes["@zotero.org/Zotero;1"]
// Currently uses only nsISupports

View File

@ -31,6 +31,13 @@ const symlinkFiles = [
// these files will be browserified during the build
const browserifyConfigs = [
{
src: 'node_modules/url/url.js',
dest: 'resource/url.js',
config: {
standalone: 'url'
}
},
{
src: 'node_modules/sinon/lib/sinon.js',
dest: 'test/resource/sinon.js',

View File

@ -12,7 +12,7 @@
<script src="resource://zotero-unit/co-mocha.js"></script>
<script src="resource://zotero-unit/sinon.js"></script>
<script src="resource://zotero-unit/pako_inflate.js"></script>
<script src="support.js" type="application/javascript;version=1.8"></script>
<script src="runtests.js" type="application/javascript;version=1.8"></script>
<script src="support.js" type="application/javascript"></script>
<script src="runtests.js" type="application/javascript"></script>
</body>
</html>

View File

@ -267,7 +267,7 @@ if(run && ZoteroUnit.tests) {
for(var fname of testFiles) {
var el = document.createElement("script");
el.type = "application/javascript;version=1.8";
el.type = "application/javascript";
el.src = "resource://zotero-unit-tests/"+fname;
el.async = false;
document.body.appendChild(el);

View File

@ -430,6 +430,52 @@ describe("Zotero.Utilities", function() {
})
});
describe("#parseURL()", function () {
var f;
before(() => {
f = Zotero.Utilities.parseURL;
});
describe("#fileName", function () {
it("should contain filename", function () {
assert.propertyVal(f('http://example.com/abc/def.html?foo=bar'), 'fileName', 'def.html');
});
it("should be empty if no filename", function () {
assert.propertyVal(f('http://example.com/abc/'), 'fileName', '');
});
});
describe("#fileExtension", function () {
it("should contain extension", function () {
assert.propertyVal(f('http://example.com/abc/def.html?foo=bar'), 'fileExtension', 'html');
});
it("should be empty if no extension", function () {
assert.propertyVal(f('http://example.com/abc/def'), 'fileExtension', '');
});
it("should be empty if no filename", function () {
assert.propertyVal(f('http://example.com/abc/'), 'fileExtension', '');
});
});
describe("#fileBaseName", function () {
it("should contain base name", function () {
assert.propertyVal(f('http://example.com/abc/def.html?foo=bar'), 'fileBaseName', 'def');
});
it("should equal filename if no extension", function () {
assert.propertyVal(f('http://example.com/abc/def'), 'fileBaseName', 'def');
});
it("should be empty if no filename", function () {
assert.propertyVal(f('http://example.com/abc/'), 'fileBaseName', '');
});
});
});
describe("#ellipsize()", function () {
describe("with wordBoundary", function () {
it("should truncate at word boundary", function* () {