Fx60: 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
This commit is contained in:
Dan Stillman 2018-02-24 04:54:53 -05:00
parent f7854bfcae
commit 78e9db9523
8 changed files with 1164 additions and 14 deletions

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

@ -161,7 +161,7 @@ Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader)
.loadSubScript('resource://zotero/require.js');
ZoteroContext = function() {}
var ZoteroContext = function() {}
ZoteroContext.prototype = {
require,

View file

@ -23,7 +23,7 @@
***** END LICENSE BLOCK *****
*/
EXPORTED_SYMBOLS = ["ConcurrentCaller"];
var EXPORTED_SYMBOLS = ["ConcurrentCaller"];
if (!(typeof process === 'object' && process + '' === '[object process]')) {
// Components.utils.import('resource://zotero/require.js');
@ -69,7 +69,7 @@ if (!(typeof process === 'object' && process + '' === '[object process]')) {
* @param {Object} [options.Promise] The Zotero instance of Promise to allow
* stubbing/spying in tests
*/
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

@ -29,5 +29,5 @@ var ZOTERO_CONFIG = {
if (typeof process === 'object' && process + '' === '[object process]'){
module.exports = ZOTERO_CONFIG;
} else {
EXPORTED_SYMBOLS = ["ZOTERO_CONFIG"];
}
var 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

@ -2,7 +2,7 @@
var require = (function() {
var win, Zotero;
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 = {};
if (typeof window != 'undefined') {

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