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: global:
secure: "NxvkbZ7/Op7BTGQRR3C4q8lLoO29f8WtyNN27NSH7AO3H0vBr1Vp5xO8gn+H2qHEug5HvM+YrZ/xAkNXaZVbOInmBmKVMxqVvdpKp9JM1Amf+gzsXWQphfySvs6iqzyP6cwU/jspdvX/WSakgU5v7PWXxtUIaKxdANt6Rw7W+Pc=" secure: "NxvkbZ7/Op7BTGQRR3C4q8lLoO29f8WtyNN27NSH7AO3H0vBr1Vp5xO8gn+H2qHEug5HvM+YrZ/xAkNXaZVbOInmBmKVMxqVvdpKp9JM1Amf+gzsXWQphfySvs6iqzyP6cwU/jspdvX/WSakgU5v7PWXxtUIaKxdANt6Rw7W+Pc="
matrix: matrix:
- FX_VERSION="52.0.3" - FX_VERSION="59.0b11"
matrix: matrix:
fast_finish: true fast_finish: true
#allow_failures: #allow_failures:
@ -22,8 +22,8 @@ addons:
packages: packages:
- dbus-x11 - dbus-x11
install: install:
- if [ $FX_VERSION = "52.0.3" ]; then - if [ $FX_VERSION = "59.0b11" ]; 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"; wget -O tarball "https://queue.taskcluster.net/v1/task/L9FO6qp_TnaLkGB_fFy0Sw/runs/0/artifacts/public/build/target.tar.bz2";
fi fi
- tar xf tarball - tar xf tarball
before_script: before_script:

View File

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

View File

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

View File

@ -139,7 +139,7 @@
<body><![CDATA[ <body><![CDATA[
return Zotero.spawn(function* () { return Zotero.spawn(function* () {
if (type == 'setting') { 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(); this.reload();
return; return;
} }
@ -227,7 +227,7 @@
// Sort tags alphabetically // Sort tags alphabetically
var collation = Zotero.getLocaleCollation(); 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++) { for (let i=0; i<tags.length; i++) {
this.addDynamicRow(tags[i], i+1); this.addDynamicRow(tags[i], i+1);
@ -682,7 +682,7 @@
return; 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 // Modifying existing tag with a single new one
if (!isNew && tags.length < 2) { 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) .getService(Components.interfaces.nsISupports)
.wrappedJSObject; .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()"> onunload="Zotero_QuickFormat.onUnload()">
<script src="../include.js"/> <script src="../include.js"/>
<script src="windowDraggingUtils.js" type="text/javascript;version=1.8"/> <script src="windowDraggingUtils.js" type="text/javascript"/>
<script src="quickFormat.js" type="text/javascript;version=1.8"/> <script src="quickFormat.js" type="text/javascript"/>
<box orient="horizontal" id="quick-format-entry"> <box orient="horizontal" id="quick-format-entry">
<deck id="quick-format-deck" selectedIndex="0" flex="1"> <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"> <overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="include.js"/> <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"> <vbox id="zotero-item-pane" zotero-persist="width height">
<!-- My Publications --> <!-- My Publications -->

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
style="padding:2em"> style="padding:2em">
<script src="../include.js"/> <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> <hbox><label>This is a test page.</label></hbox>
</window> </window>

View File

@ -1131,53 +1131,43 @@ Zotero.Attachments = new function(){
function _getFileNameFromURL(url, contentType){ function _getFileNameFromURL(url, contentType){
var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"] url = Zotero.Utilities.parseURL(url);
.createInstance(Components.interfaces.nsIURL);
nsIURL.spec = url;
var ext = Zotero.MIME.getPrimaryExtension(contentType, nsIURL.fileExtension); var fileBaseName = url.fileBaseName;
var fileExt = Zotero.MIME.getPrimaryExtension(contentType, url.fileExtension);
if (!nsIURL.fileName) { if (!fileBaseName) {
var matches = nsIURL.directory.match(/\/([^\/]+)\/$/); let matches = url.pathname.match(/\/([^\/]+)\/$/);
// If no filename, use the last part of the path if there is one // If no filename, use the last part of the path if there is one
if (matches) { if (matches) {
nsIURL.fileName = matches[1]; fileBaseName = matches[1];
} }
// Or just use the host // Or just use the host
else { else {
nsIURL.fileName = nsIURL.host; fileBaseName = url.hostname;
var tld = nsIURL.fileExtension;
} }
} }
// 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 // Test unencoding fileBaseName
try { try {
decodeURIComponent(nsIURL.fileBaseName); decodeURIComponent(fileBaseName);
} }
catch (e) { catch (e) {
if (e.name == 'URIError') { if (e.name == 'URIError') {
// If we got a 'malformed URI sequence' while decoding, // If we got a 'malformed URI sequence' while decoding,
// use MD5 of fileBaseName // use MD5 of fileBaseName
nsIURL.fileBaseName = Zotero.Utilities.Internal.md5(nsIURL.fileBaseName, false); fileBaseName = Zotero.Utilities.Internal.md5(fileBaseName, false);
} }
else { else {
throw e; throw e;
} }
} }
var fileName = fileBaseName + (fileExt ? '.' + fileExt : '');
// Pass unencoded name to getValidFileName() so that percent-encoded // Pass unencoded name to getValidFileName() so that percent-encoded
// characters aren't stripped to just numbers // 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) { "getCookiesForURI": function(uri) {
var hostParts = Zotero.CookieSandbox.normalizeHost(uri.host).split('.'), 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'; cookies = {}, found = false, secure = uri.scheme.toUpperCase() == 'HTTPS';
// Fetch cookies starting from the highest level domain // 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 * Runs synchronously, so should only be run on local (e.g. chrome) URLs
*/ */
function getContentsFromURL(url) { function getContentsFromURL(url) {
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
xmlhttp.open('GET', url, false); xmlhttp.open('GET', url, false);
xmlhttp.overrideMimeType("text/plain"); xmlhttp.overrideMimeType("text/plain");
xmlhttp.send(null); xmlhttp.send(null);

View File

@ -158,8 +158,7 @@ Zotero.HTTP = new function() {
var deferred = Zotero.Promise.defer(); var deferred = Zotero.Promise.defer();
if (!this.mock) { if (!this.mock) {
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
} }
else { else {
var xmlhttp = new this.mock; var xmlhttp = new this.mock;
@ -367,8 +366,7 @@ Zotero.HTTP = new function() {
return false; return false;
} }
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
// Prevent certificate/authentication dialogs from popping up // Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true; xmlhttp.mozBackgroundRequest = true;
@ -441,8 +439,7 @@ Zotero.HTTP = new function() {
return false; return false;
} }
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
// Prevent certificate/authentication dialogs from popping up // Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true; xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('POST', url, 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 // Workaround for "Accept third-party cookies" being off in Firefox 3.0.1
// https://www.zotero.org/trac/ticket/1070 // https://www.zotero.org/trac/ticket/1070
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
// Prevent certificate/authentication dialogs from popping up // Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true; xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('HEAD', url, true); xmlhttp.open('HEAD', url, true);
@ -567,8 +563,7 @@ Zotero.HTTP = new function() {
return false; return false;
} }
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
// Prevent certificate/authentication dialogs from popping up // Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true; xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('OPTIONS', uri.spec, true); xmlhttp.open('OPTIONS', uri.spec, true);
@ -737,8 +732,7 @@ Zotero.HTTP = new function() {
return false; return false;
} }
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
// Prevent certificate/authentication dialogs from popping up // Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true; xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('MKCOL', uri.spec, true); xmlhttp.open('MKCOL', uri.spec, true);
@ -769,8 +763,7 @@ Zotero.HTTP = new function() {
return false; return false;
} }
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] var xmlhttp = new XMLHttpRequest();
.createInstance();
// Prevent certificate/authentication dialogs from popping up // Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true; xmlhttp.mozBackgroundRequest = true;
xmlhttp.open("DELETE", uri.spec, 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 // on OS X, first try /Users/Shared for those who can't put pipes in their home
// directories // directories
var pipe = null; var pipe = null;
var sharedDir = Components.classes["@mozilla.org/file/local;1"]. var sharedDir = Zotero.File.pathToFile('/Users/Shared');
createInstance(Components.interfaces.nsILocalFile);
sharedDir.initWithPath("/Users/Shared");
if(sharedDir.exists() && sharedDir.isDirectory()) { if(sharedDir.exists() && sharedDir.isDirectory()) {
var logname = Components.classes["@mozilla.org/process/environment;1"]. var logname = Components.classes["@mozilla.org/process/environment;1"].

View File

@ -229,7 +229,7 @@ Zotero.IPC = new function() {
if(pipeDir.exists()) { if(pipeDir.exists()) {
var dirEntries = pipeDir.directoryEntries; var dirEntries = pipeDir.directoryEntries;
while (dirEntries.hasMoreElements()) { 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))) { if(pipe.leafName[0] !== "." && (!_instancePipe || !pipe.equals(_instancePipe))) {
pipes.push(pipe); pipes.push(pipe);
} }
@ -461,7 +461,12 @@ Zotero.IPC.Pipe.DeferredOpen.prototype = {
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]. var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].
createInstance(Components.interfaces.nsIInputStreamPump); createInstance(Components.interfaces.nsIInputStreamPump);
pump.init(fifoStream, -1, -1, 4096, 1, true); try {
pump.init(fifoStream, 0, 0, true);
}
catch (e) {
pump.init(fifoStream, -1, -1, 4096, 1, true);
}
pump.asyncRead(this, null); pump.asyncRead(this, null);
this._openTime = Date.now(); 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 * Queries OCLC's OpenURL resolver registry and returns an address and version
*/ */
function discoverResolvers() { 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.open("GET", "http://worldcatlibraries.org/registry/lookup?IP=requestor", false);
req.send(null); 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; Zotero.Router = Zotero.PathParser;
delete 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 dataListener = new Zotero.Server.DataListener(iStream, oStream);
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"] var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]
.createInstance(Components.interfaces.nsIInputStreamPump); .createInstance(Components.interfaces.nsIInputStreamPump);
pump.init(iStream, -1, -1, 0, 0, false); try {
pump.init(iStream, 0, 0, false);
}
catch (e) {
pump.init(iStream, -1, -1, 0, 0, false);
}
pump.asyncRead(dataListener, null); 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 = {}; var obj = {};
for (let prop of this._props) { for (let prop of this._props) {
obj[prop] = this[prop] || false; obj[prop] = this[prop] || false;
} }
return JSON.stringify(obj, null, " "); return JSON.stringify(obj, null, " ");
} }*/

View File

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

View File

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

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 * Get the real target URL from an intermediate URL
*/ */

View File

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

View File

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

View File

@ -38,14 +38,14 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="include.js"/> <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="fileInterface.js"/>
<script src="reportInterface.js"/> <script src="reportInterface.js"/>
<script src="timelineInterface.js"/> <script src="timelineInterface.js"/>
<script src="recognizePDFDialog.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="lookup.js"/>
<script src="locateMenu.js" type="application/javascript;version=1.8"/> <script src="locateMenu.js" type="application/javascript"/>
<commandset id="mainCommandSet"> <commandset id="mainCommandSet">
<command id="cmd_zotero_reportErrors" oncommand="ZoteroPane_Local.reportErrors();"/> <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"); //Zotero.debug("AsyncChannel: Got input stream from generator");
var pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(Ci.nsIInputStreamPump); var pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(Ci.nsIInputStreamPump);
pump.init(data, -1, -1, 0, 0, true); try {
pump.init(data, 0, 0, true);
}
catch (e) {
pump.init(data, -1, -1, 0, 0, true);
}
pump.asyncRead(listenerWrapper, context); pump.asyncRead(listenerWrapper, context);
} }
else if (data instanceof Ci.nsIFile || data instanceof Ci.nsIURI) { else if (data instanceof Ci.nsIFile || data instanceof Ci.nsIURI) {

View File

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

7
package-lock.json generated
View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
var EXPORTED_SYMBOLS = ["ZOTERO_CONFIG"];
var ZOTERO_CONFIG = { var ZOTERO_CONFIG = {
GUID: 'zotero@chnm.gmu.edu', GUID: 'zotero@chnm.gmu.edu',
ID: 'zotero', // used for db filename, etc. ID: 'zotero', // used for db filename, etc.
@ -25,5 +27,3 @@ var ZOTERO_CONFIG = {
FEEDBACK_URL: "https://forums.zotero.org/", FEEDBACK_URL: "https://forums.zotero.org/",
CONNECTORS_URL: "https://www.zotero.org/download/connectors" 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 * License: MIT
* https://github.com/dstillman/pathparser.js * https://github.com/dstillman/pathparser.js
*/ */
(function (factory) { (function (root, factory) {
// AMD/RequireJS // AMD/RequireJS
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define(factory); define(factory);
@ -13,14 +13,16 @@
} else if (typeof exports === 'object') { } else if (typeof exports === 'object') {
module.exports = factory(); module.exports = factory();
// Mozilla JSM // Mozilla JSM
} else if (~String(this).indexOf('BackstagePass')) { } else if (typeof Components != 'undefined'
EXPORTED_SYMBOLS = ["PathParser"]; && typeof Components.utils != 'undefined'
PathParser = factory(); && typeof Components.utils.import == 'function') {
root.EXPORTED_SYMBOLS = ["PathParser"];
root.PathParser = factory();
// Browser global // Browser global
} else { } else {
PathParser = factory(); root.PathParser = factory();
} }
}(function () { }(this, function () {
"use strict"; "use strict";
var PathParser = function (params) { var PathParser = function (params) {

View File

@ -3,7 +3,7 @@
var EXPORTED_SYMBOLS = ['require']; var EXPORTED_SYMBOLS = ['require'];
var require = (function() { 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 requirer = Module('/', '/');
var _runningTimers = {}; var _runningTimers = {};
var window = {}; var window = {};

View File

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

View File

@ -31,6 +31,13 @@ const symlinkFiles = [
// these files will be browserified during the build // these files will be browserified during the build
const browserifyConfigs = [ const browserifyConfigs = [
{
src: 'node_modules/url/url.js',
dest: 'resource/url.js',
config: {
standalone: 'url'
}
},
{ {
src: 'node_modules/sinon/lib/sinon.js', src: 'node_modules/sinon/lib/sinon.js',
dest: 'test/resource/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/co-mocha.js"></script>
<script src="resource://zotero-unit/sinon.js"></script> <script src="resource://zotero-unit/sinon.js"></script>
<script src="resource://zotero-unit/pako_inflate.js"></script> <script src="resource://zotero-unit/pako_inflate.js"></script>
<script src="support.js" type="application/javascript;version=1.8"></script> <script src="support.js" type="application/javascript"></script>
<script src="runtests.js" type="application/javascript;version=1.8"></script> <script src="runtests.js" type="application/javascript"></script>
</body> </body>
</html> </html>

View File

@ -267,7 +267,7 @@ if(run && ZoteroUnit.tests) {
for(var fname of testFiles) { for(var fname of testFiles) {
var el = document.createElement("script"); var el = document.createElement("script");
el.type = "application/javascript;version=1.8"; el.type = "application/javascript";
el.src = "resource://zotero-unit-tests/"+fname; el.src = "resource://zotero-unit-tests/"+fname;
el.async = false; el.async = false;
document.body.appendChild(el); 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("#ellipsize()", function () {
describe("with wordBoundary", function () { describe("with wordBoundary", function () {
it("should truncate at word boundary", function* () { it("should truncate at word boundary", function* () {