mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Adds the extensions/* files for jshint
This commit is contained in:
parent
d13aa38c9c
commit
fcc169453b
4 changed files with 40 additions and 25 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Mozilla Foundation
|
Copyright 2012 Mozilla Foundation
|
||||||
|
|
||||||
|
@ -13,6 +15,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
/* globals chrome */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
function isPdfDownloadable(details) {
|
function isPdfDownloadable(details) {
|
||||||
return details.url.indexOf('pdfjs.action=download') >= 0;
|
return details.url.indexOf('pdfjs.action=download') >= 0;
|
||||||
|
|
20
extensions/firefox/bootstrap.js
vendored
20
extensions/firefox/bootstrap.js
vendored
|
@ -14,16 +14,20 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
/* jshint esnext:true */
|
||||||
|
/* globals Components, Services, dump, XPCOMUtils, PdfStreamConverter,
|
||||||
|
APP_SHUTDOWN */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const RESOURCE_NAME = 'pdf.js';
|
const RESOURCE_NAME = 'pdf.js';
|
||||||
const EXT_PREFIX = 'extensions.uriloader@pdf.js';
|
const EXT_PREFIX = 'extensions.uriloader@pdf.js';
|
||||||
|
|
||||||
let Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
let Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
let Cm = Components.manager;
|
const Cm = Components.manager;
|
||||||
let Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
|
const Cr = Components.results;
|
||||||
|
|
||||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||||
Cu.import('resource://gre/modules/Services.jsm');
|
Cu.import('resource://gre/modules/Services.jsm');
|
||||||
|
@ -37,7 +41,7 @@ function getBoolPref(pref, def) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStringPref(pref, value) {
|
function setStringPref(pref, value) {
|
||||||
let str = Cc['@mozilla.org/supports-string;1']
|
var str = Cc['@mozilla.org/supports-string;1']
|
||||||
.createInstance(Ci.nsISupportsString);
|
.createInstance(Ci.nsISupportsString);
|
||||||
str.data = value;
|
str.data = value;
|
||||||
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
|
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||||
|
@ -50,7 +54,7 @@ function log(str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register/unregister a constructor as a component.
|
// Register/unregister a constructor as a component.
|
||||||
let Factory = {
|
var Factory = {
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
|
||||||
_targetConstructor: null,
|
_targetConstructor: null,
|
||||||
|
|
||||||
|
@ -73,7 +77,7 @@ let Factory = {
|
||||||
createInstance: function createInstance(aOuter, iid) {
|
createInstance: function createInstance(aOuter, iid) {
|
||||||
if (aOuter !== null)
|
if (aOuter !== null)
|
||||||
throw Cr.NS_ERROR_NO_AGGREGATION;
|
throw Cr.NS_ERROR_NO_AGGREGATION;
|
||||||
return (new (this._targetConstructor)).QueryInterface(iid);
|
return (new (this._targetConstructor)()).QueryInterface(iid);
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsIFactory
|
// nsIFactory
|
||||||
|
@ -83,7 +87,7 @@ let Factory = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let pdfStreamConverterUrl = null;
|
var pdfStreamConverterUrl = null;
|
||||||
|
|
||||||
// As of Firefox 13 bootstrapped add-ons don't support automatic registering and
|
// As of Firefox 13 bootstrapped add-ons don't support automatic registering and
|
||||||
// unregistering of resource urls and components/contracts. Until then we do
|
// unregistering of resource urls and components/contracts. Until then we do
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
/* jshint esnext:true */
|
||||||
|
/* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils,
|
||||||
|
dump */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -24,7 +27,7 @@ const Ci = Components.interfaces;
|
||||||
const Cr = Components.results;
|
const Cr = Components.results;
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
// True only if this is the version of pdf.js that is included with firefox.
|
// True only if this is the version of pdf.js that is included with firefox.
|
||||||
const MOZ_CENTRAL = PDFJSSCRIPT_MOZ_CENTRAL;
|
const MOZ_CENTRAL = JSON.parse('PDFJSSCRIPT_MOZ_CENTRAL');
|
||||||
const PDFJS_EVENT_ID = 'pdf.js.message';
|
const PDFJS_EVENT_ID = 'pdf.js.message';
|
||||||
const PDF_CONTENT_TYPE = 'application/pdf';
|
const PDF_CONTENT_TYPE = 'application/pdf';
|
||||||
const PREF_PREFIX = 'PDFJSSCRIPT_PREF_PREFIX';
|
const PREF_PREFIX = 'PDFJSSCRIPT_PREF_PREFIX';
|
||||||
|
@ -38,7 +41,7 @@ Cu.import('resource://gre/modules/NetUtil.jsm');
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, 'PrivateBrowsingUtils',
|
XPCOMUtils.defineLazyModuleGetter(this, 'PrivateBrowsingUtils',
|
||||||
'resource://gre/modules/PrivateBrowsingUtils.jsm');
|
'resource://gre/modules/PrivateBrowsingUtils.jsm');
|
||||||
|
|
||||||
let Svc = {};
|
var Svc = {};
|
||||||
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
|
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
|
||||||
'@mozilla.org/mime;1',
|
'@mozilla.org/mime;1',
|
||||||
'nsIMIMEService');
|
'nsIMIMEService');
|
||||||
|
@ -68,7 +71,7 @@ function getIntPref(pref, def) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStringPref(pref, value) {
|
function setStringPref(pref, value) {
|
||||||
let str = Cc['@mozilla.org/supports-string;1']
|
var str = Cc['@mozilla.org/supports-string;1']
|
||||||
.createInstance(Ci.nsISupportsString);
|
.createInstance(Ci.nsISupportsString);
|
||||||
str.data = value;
|
str.data = value;
|
||||||
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
|
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||||
|
@ -85,7 +88,7 @@ function getStringPref(pref, def) {
|
||||||
function log(aMsg) {
|
function log(aMsg) {
|
||||||
if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false))
|
if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false))
|
||||||
return;
|
return;
|
||||||
let msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
|
var msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
|
||||||
Services.console.logStringMessage(msg);
|
Services.console.logStringMessage(msg);
|
||||||
dump(msg + '\n');
|
dump(msg + '\n');
|
||||||
}
|
}
|
||||||
|
@ -107,7 +110,7 @@ function isEnabled() {
|
||||||
// selected in the Application preferences.
|
// selected in the Application preferences.
|
||||||
var handlerInfo = Svc.mime
|
var handlerInfo = Svc.mime
|
||||||
.getFromTypeAndExtension('application/pdf', 'pdf');
|
.getFromTypeAndExtension('application/pdf', 'pdf');
|
||||||
return handlerInfo.alwaysAskBeforeHandling == false &&
|
return !handlerInfo.alwaysAskBeforeHandling &&
|
||||||
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally;
|
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally;
|
||||||
}
|
}
|
||||||
// Always returns true for the extension since enabling/disabling is handled
|
// Always returns true for the extension since enabling/disabling is handled
|
||||||
|
@ -189,6 +192,9 @@ PdfDataListener.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onprogress: function() {},
|
onprogress: function() {},
|
||||||
|
get oncomplete() {
|
||||||
|
return this.oncompleteCallback;
|
||||||
|
},
|
||||||
set oncomplete(value) {
|
set oncomplete(value) {
|
||||||
this.oncompleteCallback = value;
|
this.oncompleteCallback = value;
|
||||||
if (this.isDataReady) {
|
if (this.isDataReady) {
|
||||||
|
@ -209,7 +215,7 @@ function ChromeActions(domWindow, dataListener, contentDispositionFilename) {
|
||||||
|
|
||||||
ChromeActions.prototype = {
|
ChromeActions.prototype = {
|
||||||
isInPrivateBrowsing: function() {
|
isInPrivateBrowsing: function() {
|
||||||
let docIsPrivate;
|
var docIsPrivate, privateBrowsing;
|
||||||
try {
|
try {
|
||||||
docIsPrivate = PrivateBrowsingUtils.isWindowPrivate(this.domWindow);
|
docIsPrivate = PrivateBrowsingUtils.isWindowPrivate(this.domWindow);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
|
@ -218,8 +224,8 @@ ChromeActions.prototype = {
|
||||||
if (typeof docIsPrivate === 'undefined') {
|
if (typeof docIsPrivate === 'undefined') {
|
||||||
// per-window Private Browsing is not supported, trying global service
|
// per-window Private Browsing is not supported, trying global service
|
||||||
try {
|
try {
|
||||||
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
||||||
.getService(Ci.nsIPrivateBrowsingService);
|
.getService(Ci.nsIPrivateBrowsingService);
|
||||||
docIsPrivate = privateBrowsing.privateBrowsingEnabled;
|
docIsPrivate = privateBrowsing.privateBrowsingEnabled;
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
// unable to get nsIPrivateBrowsingService (e.g. not Firefox)
|
// unable to get nsIPrivateBrowsingService (e.g. not Firefox)
|
||||||
|
@ -245,8 +251,8 @@ ChromeActions.prototype = {
|
||||||
var frontWindow = Cc['@mozilla.org/embedcomp/window-watcher;1'].
|
var frontWindow = Cc['@mozilla.org/embedcomp/window-watcher;1'].
|
||||||
getService(Ci.nsIWindowWatcher).activeWindow;
|
getService(Ci.nsIWindowWatcher).activeWindow;
|
||||||
|
|
||||||
let docIsPrivate = this.isInPrivateBrowsing();
|
var docIsPrivate = this.isInPrivateBrowsing();
|
||||||
let netChannel = NetUtil.newChannel(blobUri);
|
var netChannel = NetUtil.newChannel(blobUri);
|
||||||
if ('nsIPrivateBrowsingChannel' in Ci &&
|
if ('nsIPrivateBrowsingChannel' in Ci &&
|
||||||
netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
|
netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
|
||||||
netChannel.setPrivate(docIsPrivate);
|
netChannel.setPrivate(docIsPrivate);
|
||||||
|
@ -259,7 +265,7 @@ ChromeActions.prototype = {
|
||||||
}
|
}
|
||||||
// Create a nsIInputStreamChannel so we can set the url on the channel
|
// Create a nsIInputStreamChannel so we can set the url on the channel
|
||||||
// so the filename will be correct.
|
// so the filename will be correct.
|
||||||
let channel = Cc['@mozilla.org/network/input-stream-channel;1'].
|
var channel = Cc['@mozilla.org/network/input-stream-channel;1'].
|
||||||
createInstance(Ci.nsIInputStreamChannel);
|
createInstance(Ci.nsIInputStreamChannel);
|
||||||
channel.QueryInterface(Ci.nsIChannel);
|
channel.QueryInterface(Ci.nsIChannel);
|
||||||
channel.contentDisposition = Ci.nsIChannel.DISPOSITION_ATTACHMENT;
|
channel.contentDisposition = Ci.nsIChannel.DISPOSITION_ATTACHMENT;
|
||||||
|
@ -472,7 +478,7 @@ RequestListener.prototype.receive = function(event) {
|
||||||
var listener = doc.createEvent('HTMLEvents');
|
var listener = doc.createEvent('HTMLEvents');
|
||||||
listener.initEvent('pdf.js.response', true, false);
|
listener.initEvent('pdf.js.response', true, false);
|
||||||
return message.dispatchEvent(listener);
|
return message.dispatchEvent(listener);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
actions[action].call(this.actions, data, response);
|
actions[action].call(this.actions, data, response);
|
||||||
}
|
}
|
||||||
|
@ -623,9 +629,9 @@ PdfStreamConverter.prototype = {
|
||||||
var domWindow = getDOMWindow(channel);
|
var domWindow = getDOMWindow(channel);
|
||||||
// Double check the url is still the correct one.
|
// Double check the url is still the correct one.
|
||||||
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
|
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
|
||||||
let actions = new ChromeActions(domWindow, dataListener,
|
var actions = new ChromeActions(domWindow, dataListener,
|
||||||
contentDispositionFilename);
|
contentDispositionFilename);
|
||||||
let requestListener = new RequestListener(actions);
|
var requestListener = new RequestListener(actions);
|
||||||
domWindow.addEventListener(PDFJS_EVENT_ID, function(event) {
|
domWindow.addEventListener(PDFJS_EVENT_ID, function(event) {
|
||||||
requestListener.receive(event);
|
requestListener.receive(event);
|
||||||
}, false, true);
|
}, false, true);
|
||||||
|
|
6
make.js
6
make.js
|
@ -1007,9 +1007,9 @@ target.jshint = function() {
|
||||||
//'web/*.js',
|
//'web/*.js',
|
||||||
//'test/*.js',
|
//'test/*.js',
|
||||||
//'test/unit/*.js',
|
//'test/unit/*.js',
|
||||||
//'extensions/firefox/*.js',
|
'extensions/firefox/*.js',
|
||||||
//'extensions/firefox/components/*.js',
|
'extensions/firefox/components/*.js',
|
||||||
//'extensions/chrome/*.js'
|
'extensions/chrome/*.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
exit(exec('./node_modules/.bin/jshint --reporter test/reporter.js ' +
|
exit(exec('./node_modules/.bin/jshint --reporter test/reporter.js ' +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue