Adds the extensions/* files for jshint

This commit is contained in:
Yury Delendik 2013-02-02 17:37:16 -06:00
parent d13aa38c9c
commit fcc169453b
4 changed files with 40 additions and 25 deletions

View File

@ -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
@ -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
limitations under the License.
*/
/* globals chrome */
'use strict';
function isPdfDownloadable(details) {
return details.url.indexOf('pdfjs.action=download') >= 0;

View File

@ -14,16 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* jshint esnext:true */
/* globals Components, Services, dump, XPCOMUtils, PdfStreamConverter,
APP_SHUTDOWN */
'use strict';
const RESOURCE_NAME = 'pdf.js';
const EXT_PREFIX = 'extensions.uriloader@pdf.js';
let Cc = Components.classes;
let Ci = Components.interfaces;
let Cm = Components.manager;
let Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cm = Components.manager;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
@ -37,7 +41,7 @@ function getBoolPref(pref, def) {
}
function setStringPref(pref, value) {
let str = Cc['@mozilla.org/supports-string;1']
var str = Cc['@mozilla.org/supports-string;1']
.createInstance(Ci.nsISupportsString);
str.data = value;
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
@ -50,7 +54,7 @@ function log(str) {
}
// Register/unregister a constructor as a component.
let Factory = {
var Factory = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
_targetConstructor: null,
@ -73,7 +77,7 @@ let Factory = {
createInstance: function createInstance(aOuter, iid) {
if (aOuter !== null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return (new (this._targetConstructor)).QueryInterface(iid);
return (new (this._targetConstructor)()).QueryInterface(iid);
},
// 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
// unregistering of resource urls and components/contracts. Until then we do

View File

@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* jshint esnext:true */
/* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils,
dump */
'use strict';
@ -24,7 +27,7 @@ const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
// 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 PDF_CONTENT_TYPE = 'application/pdf';
const PREF_PREFIX = 'PDFJSSCRIPT_PREF_PREFIX';
@ -38,7 +41,7 @@ Cu.import('resource://gre/modules/NetUtil.jsm');
XPCOMUtils.defineLazyModuleGetter(this, 'PrivateBrowsingUtils',
'resource://gre/modules/PrivateBrowsingUtils.jsm');
let Svc = {};
var Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
'@mozilla.org/mime;1',
'nsIMIMEService');
@ -68,7 +71,7 @@ function getIntPref(pref, def) {
}
function setStringPref(pref, value) {
let str = Cc['@mozilla.org/supports-string;1']
var str = Cc['@mozilla.org/supports-string;1']
.createInstance(Ci.nsISupportsString);
str.data = value;
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
@ -85,7 +88,7 @@ function getStringPref(pref, def) {
function log(aMsg) {
if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false))
return;
let msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
var msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
Services.console.logStringMessage(msg);
dump(msg + '\n');
}
@ -107,7 +110,7 @@ function isEnabled() {
// selected in the Application preferences.
var handlerInfo = Svc.mime
.getFromTypeAndExtension('application/pdf', 'pdf');
return handlerInfo.alwaysAskBeforeHandling == false &&
return !handlerInfo.alwaysAskBeforeHandling &&
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally;
}
// Always returns true for the extension since enabling/disabling is handled
@ -189,6 +192,9 @@ PdfDataListener.prototype = {
}
},
onprogress: function() {},
get oncomplete() {
return this.oncompleteCallback;
},
set oncomplete(value) {
this.oncompleteCallback = value;
if (this.isDataReady) {
@ -209,7 +215,7 @@ function ChromeActions(domWindow, dataListener, contentDispositionFilename) {
ChromeActions.prototype = {
isInPrivateBrowsing: function() {
let docIsPrivate;
var docIsPrivate, privateBrowsing;
try {
docIsPrivate = PrivateBrowsingUtils.isWindowPrivate(this.domWindow);
} catch (x) {
@ -218,8 +224,8 @@ ChromeActions.prototype = {
if (typeof docIsPrivate === 'undefined') {
// per-window Private Browsing is not supported, trying global service
try {
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
.getService(Ci.nsIPrivateBrowsingService);
privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
.getService(Ci.nsIPrivateBrowsingService);
docIsPrivate = privateBrowsing.privateBrowsingEnabled;
} catch (x) {
// unable to get nsIPrivateBrowsingService (e.g. not Firefox)
@ -245,8 +251,8 @@ ChromeActions.prototype = {
var frontWindow = Cc['@mozilla.org/embedcomp/window-watcher;1'].
getService(Ci.nsIWindowWatcher).activeWindow;
let docIsPrivate = this.isInPrivateBrowsing();
let netChannel = NetUtil.newChannel(blobUri);
var docIsPrivate = this.isInPrivateBrowsing();
var netChannel = NetUtil.newChannel(blobUri);
if ('nsIPrivateBrowsingChannel' in Ci &&
netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
netChannel.setPrivate(docIsPrivate);
@ -259,7 +265,7 @@ ChromeActions.prototype = {
}
// Create a nsIInputStreamChannel so we can set the url on the channel
// 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);
channel.QueryInterface(Ci.nsIChannel);
channel.contentDisposition = Ci.nsIChannel.DISPOSITION_ATTACHMENT;
@ -472,7 +478,7 @@ RequestListener.prototype.receive = function(event) {
var listener = doc.createEvent('HTMLEvents');
listener.initEvent('pdf.js.response', true, false);
return message.dispatchEvent(listener);
}
};
}
actions[action].call(this.actions, data, response);
}
@ -623,9 +629,9 @@ PdfStreamConverter.prototype = {
var domWindow = getDOMWindow(channel);
// Double check the url is still the correct one.
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
let actions = new ChromeActions(domWindow, dataListener,
var actions = new ChromeActions(domWindow, dataListener,
contentDispositionFilename);
let requestListener = new RequestListener(actions);
var requestListener = new RequestListener(actions);
domWindow.addEventListener(PDFJS_EVENT_ID, function(event) {
requestListener.receive(event);
}, false, true);

View File

@ -1007,9 +1007,9 @@ target.jshint = function() {
//'web/*.js',
//'test/*.js',
//'test/unit/*.js',
//'extensions/firefox/*.js',
//'extensions/firefox/components/*.js',
//'extensions/chrome/*.js'
'extensions/firefox/*.js',
'extensions/firefox/components/*.js',
'extensions/chrome/*.js'
];
exit(exec('./node_modules/.bin/jshint --reporter test/reporter.js ' +