[Pkg-mozext-commits] [requestpolicy] 160/257: [fix] jshint: fix warnings (non-critical changes)
David Prévot
taffit at moszumanska.debian.org
Thu Jan 28 03:20:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit e4846d1acd3f4d06e477a5194df5bd52af69a58d
Author: Martin Kimmerle <dev at 256k.de>
Date: Tue Dec 1 11:08:43 2015 +0100
[fix] jshint: fix warnings (non-critical changes)
---
src/content/lib/environment.jsm | 50 ++---
src/content/lib/environment.process.js | 4 +-
.../lib/framescript-to-overlay-communication.jsm | 19 +-
src/content/lib/gui-location.jsm | 33 +--
src/content/lib/logger.jsm | 60 +++---
src/content/lib/manager-for-event-listeners.jsm | 2 +-
src/content/lib/manager-for-message-listeners.jsm | 2 +-
src/content/lib/policy-manager.alias-functions.js | 6 +-
src/content/lib/policy-manager.jsm | 78 ++++---
src/content/lib/prefs.jsm | 16 +-
src/content/lib/request-processor.compat.js | 7 +-
src/content/lib/request-processor.jsm | 47 +++--
src/content/lib/request-processor.redirects.js | 52 ++---
src/content/lib/request-set.jsm | 17 +-
src/content/lib/request.jsm | 24 +--
src/content/lib/ruleset.jsm | 187 +++++++++--------
src/content/lib/script-loader.jsm | 5 +-
src/content/lib/subscription.jsm | 117 ++++++-----
src/content/lib/utils.jsm | 6 +-
src/content/lib/utils/domains.jsm | 92 ++++-----
src/content/lib/utils/files.jsm | 17 +-
src/content/lib/utils/strings.jsm | 4 +-
src/content/lib/utils/windows.jsm | 14 +-
src/content/lib/utils/xul.jsm | 11 +-
src/content/main/about-uri.jsm | 6 +-
src/content/main/content-policy.jsm | 8 +-
src/content/main/default-pref-handler.js | 3 +-
src/content/main/pref-manager.jsm | 1 -
src/content/main/requestpolicy-service.jsm | 10 +-
src/content/main/window-manager.listener.js | 26 +--
src/content/ui/frame.blocked-content.js | 52 ++---
src/content/ui/frame.dom-content-loaded.js | 7 +-
src/content/ui/frame.js | 8 +-
src/content/ui/menu.js | 227 ++++++++++-----------
src/content/ui/overlay.js | 7 +-
src/content/ui/request-log.filtering.js | 2 +-
src/content/ui/request-log.interface.js | 3 +-
src/content/ui/request-log.js | 2 +-
src/content/ui/request-log.tree-view.js | 4 +-
src/content/ui/xul-trees.js | 2 +-
40 files changed, 630 insertions(+), 608 deletions(-)
diff --git a/src/content/lib/environment.jsm b/src/content/lib/environment.jsm
index fc6527f..8bed9e8 100644
--- a/src/content/lib/environment.jsm
+++ b/src/content/lib/environment.jsm
@@ -59,7 +59,7 @@ var Environment = (function () {
// constants, metadata
//----------------------------------------------------------------------------
- let ENV_STATES = {
+ const ENV_STATES = {
"NOT_STARTED": 0,
"STARTING_UP": 1,
"STARTUP_DONE": 2,
@@ -67,7 +67,7 @@ var Environment = (function () {
"SHUT_DOWN": 4
};
- let LEVELS = {
+ const LEVELS = {
// Essential functions do tasks that must be run first on startup and last
// on shutdown, that is they do tasks that are requirements for the Backend.
"ESSENTIAL": 1,
@@ -83,7 +83,7 @@ var Environment = (function () {
};
// a level can be entered, being processed, or finished being processed.
- let LEVEL_STATES = {
+ const LEVEL_STATES = {
"NOT_ENTERED": 0,
"PROCESSING": 1,
"FINISHED_PROCESSING": 2
@@ -104,10 +104,11 @@ var Environment = (function () {
"afterProcessing": ENV_STATES.STARTUP_DONE
},
functions: {
+ /**
+ * @this {Environment}
+ */
"beforeProcessing": function() {
- // "this" will be an environment
- let self = this;
- self.register();
+ this.register();
},
"afterProcessing": function() {}
}
@@ -127,11 +128,12 @@ var Environment = (function () {
},
functions: {
"beforeProcessing": function() {},
+ /**
+ * @this {Environment}
+ */
"afterProcessing": function() {
- // "this" will be an environment
- let self = this;
- self.innerEnvs.length = 0;
- self.unregister();
+ this.innerEnvs.length = 0;
+ this.unregister();
}
}
}
@@ -226,7 +228,7 @@ var Environment = (function () {
if (self.outerEnv) {
self.outerEnv.registerInnerEnvironment(self);
}
- }
+ };
/**
* Unregisters the environment from its outer environment.
*/
@@ -235,7 +237,7 @@ var Environment = (function () {
if (self.outerEnv) {
self.outerEnv.unregisterInnerEnvironment(self);
}
- }
+ };
/**
* Function called by an inner environment when it starts up.
*
@@ -280,7 +282,7 @@ var Environment = (function () {
// the environment is shutting down or already shut down.
return;
}
- if (self.levels["startup"][aLevel].levelState >= LEVEL_STATES.PROCESSING) {
+ if (self.levels.startup[aLevel].levelState >= LEVEL_STATES.PROCESSING) {
// Either the startup functions of the same level as `aLevel` have
// already been processed
// OR they are currently being processed.
@@ -291,7 +293,7 @@ var Environment = (function () {
// the startup process did not reach the function's level yet.
//
// ==> remember the function.
- self.levels["startup"][aLevel].functions.push(f);
+ self.levels.startup[aLevel].functions.push(f);
}
};
@@ -300,7 +302,7 @@ var Environment = (function () {
*/
Environment.prototype.addShutdownFunction = function(aLevel, f) {
let self = this;
- if (self.levels["shutdown"][aLevel].levelState >= LEVEL_STATES.PROCESSING) {
+ if (self.levels.shutdown[aLevel].levelState >= LEVEL_STATES.PROCESSING) {
// Either the shutdown functions of the same level as `aLevel` have
// already been processed
// OR they are currently being processed.
@@ -314,7 +316,7 @@ var Environment = (function () {
// level yet.
//
// ==> remember the function.
- self.levels["shutdown"][aLevel].functions.push(f);
+ self.levels.shutdown[aLevel].functions.push(f);
}
};
@@ -369,7 +371,7 @@ var Environment = (function () {
//console.debug("[RPC] function called! (" + fnArray.length +
// " functions left)");
}
- };
+ }
/**
@@ -464,25 +466,25 @@ var Environment = (function () {
functions
} = getBootstrapMetadata(aStartupOrShutdown);
- if (self.envState === envStates["beforeProcessing"]) {
+ if (self.envState === envStates.beforeProcessing) {
// #ifdef LOG_ENVIRONMENT
logStartupOrShutdown.call(self, aStartupOrShutdown);
// #endif
- functions["beforeProcessing"].call(self);
+ functions.beforeProcessing.call(self);
- self.envState = envStates["duringProcessing"];
+ self.envState = envStates.duringProcessing;
}
- if (self.envState === envStates["duringProcessing"]) {
+ if (self.envState === envStates.duringProcessing) {
processLevels.call(self, aStartupOrShutdown, aBootstrapArgs,
aUntilLevel);
if (aUntilLevel === lastLevel) {
- self.envState = envStates["afterProcessing"];
- functions["afterProcessing"].call(self);
+ self.envState = envStates.afterProcessing;
+ functions.afterProcessing.call(self);
}
}
- };
+ }
Environment.prototype.startup = function(aBootstrapArgs, aUntilLevel) {
let self = this;
diff --git a/src/content/lib/environment.process.js b/src/content/lib/environment.process.js
index d0b7ebc..357e3ce 100644
--- a/src/content/lib/environment.process.js
+++ b/src/content/lib/environment.process.js
@@ -88,7 +88,7 @@ var ProcessEnvironment = (function() {
let parentMM = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageBroadcaster);
parentMM.broadcastAsyncMessage(shutdownMessage);
- };
+ }
// Very important: The shutdown message must be sent *after*
// calling `removeDelayedFrameScript`, which is done in
@@ -185,7 +185,7 @@ var ProcessEnvironment = (function() {
// `Environment` or `Cu` is not available anymore.
//console.debug("unloading environment.jsm");
Cu.unload("chrome://rpcontinued/content/lib/environment.jsm");
- };
+ }
childMM.addMessageListener(shutdownMessage, receiveShutdownMessage);
}
diff --git a/src/content/lib/framescript-to-overlay-communication.jsm b/src/content/lib/framescript-to-overlay-communication.jsm
index 88aaf5c..022aee4 100644
--- a/src/content/lib/framescript-to-overlay-communication.jsm
+++ b/src/content/lib/framescript-to-overlay-communication.jsm
@@ -41,11 +41,11 @@ let {C} = importModule("lib/utils/constants");
* The states of the communication channel to with the overlay.
* @enum {number}
*/
-let States = Object.freeze({
+const States = {
"WAITING": 0,
"RUNNING": 1,
"STOPPED": 2
-});
+};
//==============================================================================
// FramescriptToOverlayCommunication
@@ -95,9 +95,10 @@ function FramescriptToOverlayCommunication(aEnv) {
stopCommunication.bind(null, self));
}
-function dump(self, msg) {
+FramescriptToOverlayCommunication.prototype._dump = function (msg) {
+ let self = this;
Logger.dump(self.env.uid + ": " + msg);
-}
+};
/**
* Check whether the Overlay is ready. If it is, start the
@@ -125,12 +126,12 @@ function startCommNowOrLater(self) {
*/
function startCommunication(self) {
if (self.state === States.WAITING) {
- //dump(self, "The Overlay is ready!");
+ //self._dump("The Overlay is ready!");
self.state = States.RUNNING;
while (self.waitingRunnables.length !== 0) {
let runnable = self.waitingRunnables.shift();
- //dump(self, "Lazily running function.");
+ //self._dump("Lazily running function.");
runnable.call(null);
}
}
@@ -152,17 +153,17 @@ FramescriptToOverlayCommunication.prototype.run = function(aRunnable) {
let self = this;
switch (self.state) {
case States.RUNNING:
- //dump(self, "Immediately running function.");
+ //self._dump("Immediately running function.");
aRunnable.call(null);
break;
case States.WAITING:
- //dump(self, "Remembering runnable.");
+ //self._dump("Remembering runnable.");
self.waitingRunnables.push(aRunnable);
break;
default:
- //dump(self, "Ignoring runnable.");
+ //self._dump("Ignoring runnable.");
break;
}
};
diff --git a/src/content/lib/gui-location.jsm b/src/content/lib/gui-location.jsm
index 392164c..fa439a6 100644
--- a/src/content/lib/gui-location.jsm
+++ b/src/content/lib/gui-location.jsm
@@ -47,7 +47,7 @@ function GUILocation(value, properties) {
GUILocation.prototype.toString = function() {
return this.value;
-}
+};
/**
* @static
@@ -95,19 +95,19 @@ GUILocation.sortByNumRequestsCompareFunction = function (a, b) {
return GUILocation.compareFunction(a, b, "sortByNumRequests");
};
GUILocation.compareFunction = function (a, b, sortType) {
- var a_default = (a.properties.numDefaultPolicyRequests > 0);
- var b_default = (b.properties.numDefaultPolicyRequests > 0);
+ var a_default = 0 < a.properties.numDefaultPolicyRequests;
+ var b_default = 0 < b.properties.numDefaultPolicyRequests;
if (a_default !== b_default) {
if (a_default === true) {
// default-policy destinations first.
return -1;
} else {
- return 1
+ return 1;
}
}
- if (sortType == "sortByNumRequests") {
+ if (sortType === "sortByNumRequests") {
if (a.properties.numRequests > b.properties.numRequests) {
return -1;
}
@@ -116,7 +116,6 @@ GUILocation.compareFunction = function (a, b, sortType) {
}
}
-
if (a.value > b.value) {
return 1;
}
@@ -138,7 +137,7 @@ GUILocation.compareFunction = function (a, b, sortType) {
function GUIOrigin(origin, properties) {
GUILocation.call(this, origin, properties);
}
-GUIOrigin.prototype = new GUILocation;
+GUIOrigin.prototype = new GUILocation();
/**
* @static
@@ -158,7 +157,7 @@ GUIOrigin.indexOfOriginInArray = GUILocation.indexOfLocationInArray;
function GUIDestination(dest, properties) {
GUILocation.call(this, dest, properties);
}
-GUIDestination.prototype = new GUILocation;
+GUIDestination.prototype = new GUILocation();
/**
* @static
@@ -193,24 +192,27 @@ GUILocationProperties.prototype.reset = function() {
* Otherwise the ruleAction will be checked for every single request.
*/
GUILocationProperties.prototype.accumulate = function (requests, ruleAction) {
- var extractRuleActions = (undefined === ruleAction);
+ var extractRuleActions = undefined === ruleAction;
var ruleActionCounter = 0;
- for (var destIdent in requests) {
- for (var destUri in requests[destIdent]) {
- for (var i in requests[destIdent][destUri]) {
+ for (let destIdent in requests) {
+ let destIdentRequests = requests[destIdent];
+ for (let destUri in destIdentRequests) {
+ let destUriRequests = destIdentRequests[destUri];
+ for (let i in destUriRequests) {
+ let request = destUriRequests[i];
++this.numRequests;
// depending on ruleAction:
if (!extractRuleActions) {
++ruleActionCounter;
- } else if (requests[destIdent][destUri][i].isAllowed) {
+ } else if (request.isAllowed) {
++this.numAllowedRequests;
} else {
++this.numBlockedRequests;
}
- if ( requests[destIdent][destUri][i].isDefaultPolicyUsed() ) {
+ if (request.isDefaultPolicyUsed()) {
++this.numDefaultPolicyRequests;
}
}
@@ -250,8 +252,7 @@ GUILocationProperties.merge = function (prop1, prop2) {
var requestCountProperties = GUILocationProperties.requestCountProperties;
var newObj = new GUILocationProperties();
- for (var i in requestCountProperties) {
- var propertyName = requestCountProperties[i];
+ for (let propertyName of requestCountProperties) {
newObj[propertyName] += prop1[propertyName] + prop2[propertyName];
}
diff --git a/src/content/lib/logger.jsm b/src/content/lib/logger.jsm
index 6971c44..0c75a18 100644
--- a/src/content/lib/logger.jsm
+++ b/src/content/lib/logger.jsm
@@ -84,6 +84,20 @@ var Logger = (function() {
let initialized = false;
+ /**
+ * This function will be called in case Logger isn't fully initialized yet.
+ */
+ function initialLog() {
+ init();
+ log.apply(this, arguments);
+ }
+
+ /**
+ * Initially call initialLog() on doLog().
+ * After initialization it will be log().
+ */
+ let doLog = initialLog;
+
// initially, enable logging. later the logging preferences of the user will
// will be loaded.
let enabled = true;
@@ -92,7 +106,7 @@ var Logger = (function() {
let level = self.LEVEL_INFO;
let types = self.TYPE_ALL;
- function updateLoggingSettings(rp) {
+ function updateLoggingSettings() {
enabled = rpPrefBranch.getBoolPref("log");
level = rpPrefBranch.getIntPref("log.level");
types = rpPrefBranch.getIntPref("log.types");
@@ -130,16 +144,10 @@ var Logger = (function() {
- /**
- * This function will be called in case Logger isn't fully initialized yet.
- */
- let initialLog = function() {
- init();
- log.apply(this, arguments);
- };
- let log = function(aLevel, aType, aMessage, aError) {
- let shouldLog = (enabled && aLevel >= level && types & aType);
+
+ function log(aLevel, aType, aMessage, aError) {
+ let shouldLog = enabled && aLevel >= level && types & aType;
// #ifdef UNIT_TESTING
if (aType === self.TYPE_ERROR || aLevel === self.LEVEL_SEVERE) {
@@ -157,18 +165,12 @@ var Logger = (function() {
let levelName = self._LEVEL_NAMES[aLevel.toString()];
let typeName = self._TYPE_NAMES[aType.toString()];
- let stack = (aError && aError.stack) ?
+ let stack = aError && aError.stack ?
", stack was:\n" + aError.stack : "";
- self.printFunc("[RequestPolicy] [" + levelName + "] [" + typeName + "] "
- + aMessage + stack + "\n");
+ self.printFunc("[RequestPolicy] [" + levelName + "] " +
+ "[" + typeName + "] " + aMessage + stack + "\n");
}
- };
-
- /**
- * Initially call initialLog() on doLog().
- * After initialization it will be log().
- */
- let doLog = initialLog;
+ }
@@ -185,19 +187,23 @@ var Logger = (function() {
} else {
self.dump(obj);
}
- for (var i in obj) {
+ // Iterate through all keys in the whole prototype chain.
+ /* jshint -W089 */ // don't require checking hasOwnProperty()
+ for (let key in obj) {
+ let value = obj[key];
try {
- if (typeof obj[i] == 'function') {
+ if (typeof value === "function") {
if (!ignoreFunctions) {
- self.dump(" => key: " + i + " / value: instanceof Function");
+ self.dump(" => key: " + key + " / value: instanceof Function");
}
} else {
- self.dump(" => key: " + i + " / value: " + obj[i]);
+ self.dump(" => key: " + key + " / value: " + value);
}
} catch (e) {
- self.dump(" => key: " + i + " / value: [unable to access value]");
+ self.dump(" => key: " + key + " / value: [unable to access value]");
}
}
+ /* jshint +W089 */
};
return self;
@@ -239,7 +245,7 @@ var UnitTestObserver = (function () {
function splitColon(aString) {
var index = aString.indexOf(":");
if (index === -1) {
- return [aString, ""]
+ return [aString, ""];
}
var part1 = aString.substr(0, index);
var part2 = aString.substr(index + 1);
@@ -270,7 +276,7 @@ var UnitTestObserver = (function () {
};
function produceReferenceError() {
- var localVar = nonexistantVariable;
+ var localVar = nonexistantVariable; // jshint ignore:line
}
function runAsync(aFunction) {
diff --git a/src/content/lib/manager-for-event-listeners.jsm b/src/content/lib/manager-for-event-listeners.jsm
index a5bc44d..1a8993f 100644
--- a/src/content/lib/manager-for-event-listeners.jsm
+++ b/src/content/lib/manager-for-event-listeners.jsm
@@ -91,7 +91,7 @@ function addEvLis(listener) {
listener.target.addEventListener(listener.eventType, listener.callback,
listener.useCapture);
listener.listening = true;
-};
+}
ManagerForEventListeners.prototype.addListener = function(aEventTarget,
diff --git a/src/content/lib/manager-for-message-listeners.jsm b/src/content/lib/manager-for-message-listeners.jsm
index c30d58f..f965a52 100644
--- a/src/content/lib/manager-for-message-listeners.jsm
+++ b/src/content/lib/manager-for-message-listeners.jsm
@@ -122,7 +122,7 @@ ManagerForMessageListeners.prototype.addListener = function(aMessageName,
"The message name that has been passed to " +
"`addListener()` contains the MM Prefix. " +
"Extracting the message name.");
- aMessageName = aMessageName.substr(C.MM_PREFIX.length)
+ aMessageName = aMessageName.substr(C.MM_PREFIX.length);
}
let listener = {
diff --git a/src/content/lib/policy-manager.alias-functions.js b/src/content/lib/policy-manager.alias-functions.js
index 6595f8c..25d038a 100644
--- a/src/content/lib/policy-manager.alias-functions.js
+++ b/src/content/lib/policy-manager.alias-functions.js
@@ -52,10 +52,10 @@ PolicyManager = (function(self) {
function getRuleData(aOrigin, aDest) {
let ruleData = {};
if (aOrigin !== undefined) {
- ruleData["o"] = {"h": aOrigin};
+ ruleData.o = {"h": aOrigin};
}
if (aDest !== undefined) {
- ruleData["d"] = {"h": aDest};
+ ruleData.d = {"h": aDest};
}
return ruleData;
}
@@ -93,7 +93,7 @@ PolicyManager = (function(self) {
function allowOriginToDestination(originIdentifier, destIdentifier, noStore) {
self.addAllowRule(getRuleData(originIdentifier, destIdentifier), noStore);
- };
+ }
self.allowOriginToDestination = function(originIdentifier, destIdentifier) {
allowOriginToDestination(originIdentifier, destIdentifier, false);
};
diff --git a/src/content/lib/policy-manager.jsm b/src/content/lib/policy-manager.jsm
index c200f78..dd2c935 100644
--- a/src/content/lib/policy-manager.jsm
+++ b/src/content/lib/policy-manager.jsm
@@ -48,11 +48,7 @@ const RULES_CHANGED_TOPIC = "rpcontinued-rules-changed";
//==============================================================================
function dprint(msg) {
- if (typeof print == "function") {
- print(msg);
- } else {
- Logger.info(Logger.TYPE_POLICY, msg);
- }
+ Logger.info(Logger.TYPE_POLICY, msg);
}
function warn(msg) {
@@ -87,8 +83,8 @@ var PolicyManager = (function () {
//self._rulesets = null;
self.getUserRuleCount = function() {
- return userRulesets["user"]["rawRuleset"].getAllowRuleCount() +
- userRulesets["user"]["rawRuleset"].getDenyRuleCount();
+ let rawRuleset = userRulesets.user.rawRuleset;
+ return rawRuleset.getAllowRuleCount() + rawRuleset.getDenyRuleCount();
};
self.loadUserRules = function() {
@@ -104,12 +100,12 @@ var PolicyManager = (function () {
// we'll assume this is a new install.
rawRuleset = new RawRuleset();
}
- userRulesets["user"] = {
+ userRulesets.user = {
"rawRuleset" : rawRuleset,
"ruleset" : rawRuleset.toRuleset("user")
};
- userRulesets["user"]["ruleset"].userRuleset = true;
- //userRulesets["user"].ruleset.print();
+ userRulesets.user.ruleset.userRuleset = true;
+ //userRulesets.user.ruleset.print();
// Temporary rules. These are never stored.
self.revokeTemporaryRules();
@@ -144,7 +140,7 @@ var PolicyManager = (function () {
"rawRuleset" : rawRuleset,
"ruleset" : rawRuleset.toRuleset(subName)
};
- list[subName]["ruleset"].userRuleset = false;
+ list[subName].ruleset.userRuleset = false;
//list[subName].ruleset.print();
}
}
@@ -204,14 +200,14 @@ var PolicyManager = (function () {
};
self.addRule = function(ruleAction, ruleData, noStore) {
- dprint("PolicyManager::addRule " + ruleAction + " "
- + Ruleset.rawRuleToCanonicalString(ruleData));
- //userRulesets["user"].ruleset.print();
+ dprint("PolicyManager::addRule " + ruleAction + " " +
+ Ruleset.rawRuleToCanonicalString(ruleData));
+ //userRulesets.user.ruleset.print();
assertRuleAction(ruleAction);
// TODO: check rule format validity
- userRulesets["user"].rawRuleset.addRule(ruleAction, ruleData,
- userRulesets["user"].ruleset);
+ userRulesets.user.rawRuleset.addRule(ruleAction, ruleData,
+ userRulesets.user.ruleset);
// TODO: only save if we actually added a rule. This will require
// modifying |RawRuleset.addRule()| to indicate whether a rule
@@ -220,10 +216,10 @@ var PolicyManager = (function () {
// become annoying when there is a large file to write.
if (!noStore) {
RulesetStorage.saveRawRulesetToFile(
- userRulesets["user"].rawRuleset, "user.json");
+ userRulesets.user.rawRuleset, "user.json");
}
- //userRulesets["user"].ruleset.print();
+ //userRulesets.user.ruleset.print();
notifyRulesChanged();
};
@@ -239,37 +235,37 @@ var PolicyManager = (function () {
self.storeRules = function() {
RulesetStorage.saveRawRulesetToFile(
- userRulesets["user"].rawRuleset, "user.json");
+ userRulesets.user.rawRuleset, "user.json");
};
self.addTemporaryRule = function(ruleAction, ruleData) {
- dprint("PolicyManager::addTemporaryRule " + ruleAction + " "
- + Ruleset.rawRuleToCanonicalString(ruleData));
- //userRulesets["temp"].ruleset.print();
+ dprint("PolicyManager::addTemporaryRule " + ruleAction + " " +
+ Ruleset.rawRuleToCanonicalString(ruleData));
+ //userRulesets.temp.ruleset.print();
assertRuleAction(ruleAction);
// TODO: check rule format validity
- userRulesets["temp"].rawRuleset.addRule(ruleAction, ruleData,
- userRulesets["temp"].ruleset);
+ userRulesets.temp.rawRuleset.addRule(ruleAction, ruleData,
+ userRulesets.temp.ruleset);
- //userRulesets["temp"].ruleset.print();
+ //userRulesets.temp.ruleset.print();
notifyRulesChanged();
};
self.removeRule = function(ruleAction, ruleData, noStore) {
- dprint("PolicyManager::removeRule " + ruleAction + " "
- + Ruleset.rawRuleToCanonicalString(ruleData));
- //userRulesets["user"].ruleset.print();
- //userRulesets["temp"].ruleset.print();
+ dprint("PolicyManager::removeRule " + ruleAction + " " +
+ Ruleset.rawRuleToCanonicalString(ruleData));
+ //userRulesets.user.ruleset.print();
+ //userRulesets.temp.ruleset.print();
assertRuleAction(ruleAction);
// TODO: check rule format validity
// TODO: use noStore
- userRulesets["user"].rawRuleset.removeRule(ruleAction, ruleData,
- userRulesets["user"].ruleset);
- userRulesets["temp"].rawRuleset.removeRule(ruleAction, ruleData,
- userRulesets["temp"].ruleset);
+ userRulesets.user.rawRuleset.removeRule(ruleAction, ruleData,
+ userRulesets.user.ruleset);
+ userRulesets.temp.rawRuleset.removeRule(ruleAction, ruleData,
+ userRulesets.temp.ruleset);
// TODO: only save if we actually removed a rule. This will require
// modifying |RawRuleset.removeRule()| to indicate whether a rule
@@ -278,27 +274,27 @@ var PolicyManager = (function () {
// become annoying when there is a large file to write.
if (!noStore) {
RulesetStorage.saveRawRulesetToFile(
- userRulesets["user"].rawRuleset, "user.json");
+ userRulesets.user.rawRuleset, "user.json");
}
- //userRulesets["user"].ruleset.print();
- //userRulesets["temp"].ruleset.print();
+ //userRulesets.user.ruleset.print();
+ //userRulesets.temp.ruleset.print();
notifyRulesChanged();
};
self.temporaryRulesExist = function() {
- return userRulesets["temp"].rawRuleset.getAllowRuleCount() ||
- userRulesets["temp"].rawRuleset.getDenyRuleCount();
+ return userRulesets.temp.rawRuleset.getAllowRuleCount() ||
+ userRulesets.temp.rawRuleset.getDenyRuleCount();
};
self.revokeTemporaryRules = function() {
var rawRuleset = new RawRuleset();
- userRulesets["temp"] = {
+ userRulesets.temp = {
"rawRuleset" : rawRuleset,
"ruleset" : rawRuleset.toRuleset("temp")
};
- userRulesets["temp"]["ruleset"].userRuleset = true;
+ userRulesets.temp.ruleset.userRuleset = true;
notifyRulesChanged();
};
@@ -343,7 +339,7 @@ var PolicyManager = (function () {
}
}
return result;
- };
+ }
return self;
}());
diff --git a/src/content/lib/prefs.jsm b/src/content/lib/prefs.jsm
index 203b8da..211bf8d 100644
--- a/src/content/lib/prefs.jsm
+++ b/src/content/lib/prefs.jsm
@@ -50,10 +50,6 @@ var rootPrefBranch = Services.prefs.getBranch("")
var Prefs = (function() {
let self = {};
- let defaultAllow = true;
- let defaultAllowSameDomain = true;
- let blockingDisabled = false;
-
self.save = function() {
@@ -80,7 +76,7 @@ var Prefs = (function() {
* `Prefs.getter_function_name()` and `Prefs.setter_function_name()`.
* Those functions will be added to `self` subsequently.
*/
- let rpPrefAliases = {
+ const RP_PREF_ALIASES = {
"bool": {
"defaultPolicy.allow": "DefaultAllow",
"defaultPolicy.allowSameDomain": "DefaultAllowSameDomain",
@@ -96,8 +92,8 @@ var Prefs = (function() {
* `setBlockingDisabled`.
*/
{
- for (let prefID in rpPrefAliases.bool) {
- let prefName = rpPrefAliases.bool[prefID];
+ for (let prefID in RP_PREF_ALIASES.bool) {
+ let prefName = RP_PREF_ALIASES.bool[prefID];
// define the pref's getter function to `self`
self["is"+prefName] = getRPBoolPref.bind(this, prefID);
@@ -108,8 +104,8 @@ var Prefs = (function() {
}
self.isPrefetchEnabled = function() {
- return rootPrefBranch.getBoolPref("network.prefetch-next")
- || !rootPrefBranch.getBoolPref("network.dns.disablePrefetch");
+ return rootPrefBranch.getBoolPref("network.prefetch-next") ||
+ !rootPrefBranch.getBoolPref("network.dns.disablePrefetch");
};
function isPrefEmpty(pref) {
@@ -147,7 +143,7 @@ var Prefs = (function() {
// TODO: also send the pref's name and its branch
Services.obs.notifyObservers(null, "rpcontinued-prefs-changed", null);
}
- };
+ }
function registerPrefObserver() {
// observe everything on RP's pref branch
diff --git a/src/content/lib/request-processor.compat.js b/src/content/lib/request-processor.compat.js
index df63ead..ee7f778 100644
--- a/src/content/lib/request-processor.compat.js
+++ b/src/content/lib/request-processor.compat.js
@@ -38,9 +38,6 @@ let {Logger} = importModule("lib/logger");
//==============================================================================
RequestProcessor = (function(self) {
- let internal = Utils.moduleInternal(self);
-
-
let conflictingExtensions = [];
let compatibilityRules = [];
let topLevelDocTranslationRules = {};
@@ -278,7 +275,7 @@ RequestProcessor = (function(self) {
compatibilityRules.push(["about:newtab", null, appInfo.vendor]);
// Flock
- if (appInfo.ID == "{a463f10c-3994-11da-9945-000d60ca027b}") {
+ if (appInfo.ID === "{a463f10c-3994-11da-9945-000d60ca027b}") {
Logger.info(Logger.TYPE_INTERNAL,
"Application detected: " + appInfo.vendor);
compatibilityRules.push(
@@ -297,7 +294,7 @@ RequestProcessor = (function(self) {
}
// Seamonkey
- if (appInfo.ID == "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}") {
+ if (appInfo.ID === "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}") {
Logger.info(Logger.TYPE_INTERNAL, "Application detected: Seamonkey");
compatibilityRules.push(["mailbox:", null, "Seamonkey"]);
compatibilityRules.push([null, "mailbox:", "Seamonkey"]);
diff --git a/src/content/lib/request-processor.jsm b/src/content/lib/request-processor.jsm
index 722cbc8..7dbac38 100644
--- a/src/content/lib/request-processor.jsm
+++ b/src/content/lib/request-processor.jsm
@@ -192,7 +192,7 @@ var RequestProcessor = (function () {
request.requestResult);
self._allowedRequests.removeRequest(request.originURI, request.destURI);
notifyRequestObserversOfBlockedRequest(request);
- }
+ };
// We only call this from shouldLoad when the request was a remote request
// initiated by the content of a page. this is partly for efficiency. in other
@@ -392,8 +392,8 @@ var RequestProcessor = (function () {
function _addRecursivelyAllRequestsFromURI(originURI, reqSet,
checkedOrigins) {
- Logger.dump("Looking for other origins within allowed requests from "
- + originURI);
+ Logger.dump("Looking for other origins within allowed requests from " +
+ originURI);
if (!checkedOrigins[originURI]) {
// this "if" is needed for the first call of this function.
checkedOrigins[originURI] = true;
@@ -405,8 +405,8 @@ var RequestProcessor = (function () {
for (var destBase in allowedRequests) {
for (var destIdent in allowedRequests[destBase]) {
for (var destURI in allowedRequests[destBase][destIdent]) {
- Logger.dump("Found allowed request to <"
- + destURI + "> from <" + originURI + ">");
+ Logger.dump("Found allowed request to <" + destURI + "> " +
+ "from <" + originURI + ">");
reqSet.addRequest(originURI, destURI,
allowedRequests[destBase][destIdent][destURI]);
@@ -523,8 +523,8 @@ var RequestProcessor = (function () {
if (request.aRequestOrigin.scheme == "view-source") {
var newOriginURI = originURI.split(":").slice(1).join(":");
Logger.info(Logger.TYPE_CONTENT,
- "Considering view-source origin <"
- + originURI + "> to be origin <" + newOriginURI + ">");
+ "Considering view-source origin <" + originURI + "> " +
+ "to be origin <" + newOriginURI + ">");
originURI = newOriginURI;
request.setOriginURI(originURI);
}
@@ -534,13 +534,13 @@ var RequestProcessor = (function () {
if (newDestURI.indexOf("data:text/html") == 0) {
// "View Selection Source" has been clicked
Logger.info(Logger.TYPE_CONTENT,
- "Allowing \"data:text/html\" view-source destination"
- + " (Selection Source)");
+ "Allowing \"data:text/html\" view-source destination" +
+ " (Selection Source)");
return CP_OK;
} else {
Logger.info(Logger.TYPE_CONTENT,
- "Considering view-source destination <"
- + destURI + "> to be destination <" + newDestURI + ">");
+ "Considering view-source destination <" + destURI + "> " +
+ "to be destination <" + newDestURI + ">");
destURI = newDestURI;
request.setDestURI(destURI);
}
@@ -585,8 +585,8 @@ var RequestProcessor = (function () {
// http://code.google.com/p/SOME_PROJECT/source/detail?r=SOME_REVISION
if (originURI == destURI) {
Logger.warning(Logger.TYPE_CONTENT,
- "Allowing (but not recording) request "
- + "where origin is the same as the destination: " + originURI);
+ "Allowing (but not recording) request " +
+ "where origin is the same as the destination: " + originURI);
return CP_OK;
}
@@ -658,8 +658,8 @@ var RequestProcessor = (function () {
request.requestResult = new RequestResult(true,
REQUEST_REASON_HISTORY_REQUEST);
return accept("History request", request, true);
- } else if (internal.userAllowedRedirects[originURI]
- && internal.userAllowedRedirects[originURI][destURI]) {
+ } else if (internal.userAllowedRedirects[originURI] &&
+ internal.userAllowedRedirects[originURI][destURI]) {
// shouldLoad is called by location.href in overlay.js as of Fx
// 3.7a5pre and SeaMonkey 2.1a.
request.requestResult = new RequestResult(true,
@@ -674,8 +674,9 @@ var RequestProcessor = (function () {
request.requestResult = new RequestResult(true,
REQUEST_REASON_USER_ACTION);
return accept(
- "User action (e.g. address entered in address bar) or other good "
- + "explanation (e.g. new window/tab opened)", request);
+ "User action (e.g. address entered in address bar) " +
+ "or other good explanation (e.g. new window/tab opened)",
+ request);
} else {
// TODO: It seems sketchy to allow all requests from chrome. If I
// had to put my money on a possible bug (in terms of not blocking
@@ -687,8 +688,9 @@ var RequestProcessor = (function () {
request.requestResult = new RequestResult(true,
REQUEST_REASON_USER_ACTION);
return accept(
- "User action (e.g. address entered in address bar) or other good "
- + "explanation (e.g. new window/tab opened)", request);
+ "User action (e.g. address entered in address bar) " +
+ "or other good explanation (e.g. new window/tab opened)",
+ request);
}
}
@@ -950,7 +952,8 @@ var RequestProcessor = (function () {
};
self.registerLinkClicked = function(originUrl, destinationUrl) {
- originUrl = DomainUtil.ensureUriHasPath(DomainUtil.stripFragment(originUrl));
+ originUrl = DomainUtil.ensureUriHasPath(
+ DomainUtil.stripFragment(originUrl));
destinationUrl = DomainUtil.ensureUriHasPath(
DomainUtil.stripFragment(destinationUrl));
@@ -1007,8 +1010,8 @@ var RequestProcessor = (function () {
*/
self.addRequestObserver = function(observer) {
if (!("observeBlockedRequest" in observer)) {
- throw "Observer passed to addRequestObserver does "
- + "not have an observeBlockedRequest() method.";
+ throw "Observer passed to addRequestObserver does " +
+ "not have an observeBlockedRequest() method.";
}
Logger.debug(Logger.TYPE_INTERNAL,
"Adding request observer: " + observer.toString());
diff --git a/src/content/lib/request-processor.redirects.js b/src/content/lib/request-processor.redirects.js
index bc4bf79..26218eb 100644
--- a/src/content/lib/request-processor.redirects.js
+++ b/src/content/lib/request-processor.redirects.js
@@ -141,8 +141,7 @@ RequestProcessor = (function(self) {
}
// fixme: "//example.com/path" is also a valid relative URL
- if (destURI[0] && destURI[0] == '/'
- || destURI.indexOf(":") == -1) {
+ if (destURI[0] && destURI[0] === "/" || destURI.indexOf(":") === -1) {
// Redirect is to a relative url.
// ==> allow.
return new RequestResult(true, REQUEST_REASON_RELATIVE_URL);
@@ -165,7 +164,7 @@ RequestProcessor = (function(self) {
self.isAllowedRedirect = function(originURI, destURI) {
var request = new Request(originURI, destURI);
- return (true === checkRedirect(request).isAllowed);
+ return true === checkRedirect(request).isAllowed;
};
@@ -186,9 +185,10 @@ RequestProcessor = (function(self) {
request.requestResult = checkRedirect(request);
if (true === request.requestResult.isAllowed) {
- Logger.warning(Logger.TYPE_HEADER_REDIRECT, "** ALLOWED ** '"
- + headerType + "' header to <" + destURI + "> " + "from <" + originURI
- + ">. Same hosts or allowed origin/destination.");
+ Logger.warning(Logger.TYPE_HEADER_REDIRECT,
+ "** ALLOWED ** '" + headerType + "' header to <" + destURI + "> " +
+ "from <" + originURI + ">. " +
+ "Same hosts or allowed origin/destination.");
internal.recordAllowedRequest(originURI, destURI, false,
request.requestResult);
internal.allowedRedirectsReverse[destURI] = originURI;
@@ -209,8 +209,8 @@ RequestProcessor = (function(self) {
"from <" + realOrigin + ">");
self.registerLinkClicked(realOrigin, destURI);
- } else if (internal.submittedForms[realOrigin]
- && internal.submittedForms[realOrigin][originURI.split("?")[0]]) {
+ } else if (internal.submittedForms[realOrigin] &&
+ internal.submittedForms[realOrigin][originURI.split("?")[0]]) {
Logger.warning(Logger.TYPE_HEADER_REDIRECT,
"This redirect was from a form submission." +
" Registering an additional form submission to <" + destURI +
@@ -262,9 +262,12 @@ RequestProcessor = (function(self) {
// fixme: bad smell! the same link (linkClickDest) could have
// been clicked from different origins!
for (let i in internal.clickedLinksReverse[linkClickDest]) {
- // We hope there's only one possibility of a source page (that is,
- // ideally there will be one iteration of this loop).
- linkClickOrigin = i;
+ if (internal.clickedLinksReverse[linkClickDest].
+ hasOwnProperty(i)) {
+ // We hope there's only one possibility of a source page
+ // (that is,ideally there will be one iteration of this loop).
+ linkClickOrigin = i;
+ }
}
// TODO: #633 - Review the following line (recordAllowedRequest).
@@ -330,12 +333,14 @@ RequestProcessor = (function(self) {
}
}
- showRedirectNotification(aRequest) || Logger.warning(
- Logger.TYPE_HEADER_REDIRECT,
- "A redirection of a top-level document has been observed, " +
- "but it was not possible to notify the user! The redirection " +
- "was from page <" + request.originURI + "> " +
- "to <" + request.destURI + ">.");
+ let rv = showRedirectNotification(aRequest);
+ if (true !== rv) {
+ Logger.warning(Logger.TYPE_HEADER_REDIRECT,
+ "A redirection of a top-level document has been observed, " +
+ "but it was not possible to notify the user! The redirection " +
+ "was from page <" + aRequest.originURI + "> " +
+ "to <" + aRequest.destURI + ">.");
+ }
}
/**
@@ -353,7 +358,7 @@ RequestProcessor = (function(self) {
const ASSUME_REDIRECT_LOOP = 100; // Chosen arbitrarily.
for (let i = 0; i < ASSUME_REDIRECT_LOOP; ++i) {
- if (false === (initialOrigin in internal.allowedRedirectsReverse)) {
+ if (!internal.allowedRedirectsReverse.hasOwnProperty(initialOrigin)) {
// break the loop
break;
}
@@ -410,10 +415,11 @@ RequestProcessor = (function(self) {
// If the redirected request is allowed, we need to know that was a
// favicon request in case it is further redirected.
internal.faviconRequests[rawDestString] = true;
- Logger.info(Logger.TYPE_HEADER_REDIRECT, "'" + httpResponse.redirHeaderType
- + "' header to <" + rawDestString + "> " + "from <" + originString
- + "> appears to be a redirected favicon request. "
- + "This will be treated as a content request.");
+ Logger.info(Logger.TYPE_HEADER_REDIRECT,
+ "'" + httpResponse.redirHeaderType + "' header " +
+ "to <" + rawDestString + "> " + "from <" + originString + "> " +
+ "appears to be a redirected favicon request. " +
+ "This will be treated as a content request.");
} else {
Logger.warning(Logger.TYPE_HEADER_REDIRECT,
"** ALLOWED ** '" + httpResponse.redirHeaderType +
@@ -426,7 +432,7 @@ RequestProcessor = (function(self) {
var request = new RedirectRequest(httpResponse);
processUrlRedirection(request);
- };
+ }
diff --git a/src/content/lib/request-set.jsm b/src/content/lib/request-set.jsm
index 1d118ea..1fdea3a 100644
--- a/src/content/lib/request-set.jsm
+++ b/src/content/lib/request-set.jsm
@@ -106,11 +106,12 @@ RequestSet.prototype = {
}
for (var destUri in dests[destBase][destIdent]) {
if (!result[destBase][destIdent][destUri]) {
- result[destBase][destIdent][destUri] = dests[destBase][destIdent][destUri];
+ result[destBase][destIdent][destUri] =
+ dests[destBase][destIdent][destUri];
} else {
result[destBase][destIdent][destUri] =
- result[destBase][destIdent][destUri]
- .concat(dests[destBase][destIdent][destUri]);
+ result[destBase][destIdent][destUri].
+ concat(dests[destBase][destIdent][destUri]);
}
}
}
@@ -129,11 +130,9 @@ RequestSet.prototype = {
addRequest : function(originUri, destUri, requestResult) {
if (requestResult == undefined) {
Logger.warning(Logger.TYPE_INTERNAL,
- "addRequest() was called without a requestResult object!"
- +" Creating a new one.\n"
- +"\torigin: <"+originUri+">\n"
- +"\tdestination: <"+destUri+">"
- );
+ "addRequest() was called without a requestResult object!" +
+ " Creating a new one. -- " +
+ "origin: <" + originUri + ">, destination: <" + destUri + ">");
requestResult = new RequestResult();
}
@@ -225,7 +224,7 @@ RequestSet.prototype = {
},
containsBlockedRequests : function() {
- var origins = this._origins
+ var origins = this._origins;
for (var originURI in origins) {
for (var destBase in origins[originURI]) {
for (var destIdent in origins[originURI][destBase]) {
diff --git a/src/content/lib/request.jsm b/src/content/lib/request.jsm
index 579717a..1f5c8e3 100644
--- a/src/content/lib/request.jsm
+++ b/src/content/lib/request.jsm
@@ -119,12 +119,12 @@ NormalRequest.prototype.setDestURI = function(destURI) {
NormalRequest.prototype.detailsToString = function() {
// Note: try not to cause side effects of toString() during load, so "<HTML
// Element>" is hard-coded.
+ let context = this.aContext instanceof Ci.nsIDOMHTMLElement ?
+ "<HTML Element>" : this.aContext;
return "type: " + this.aContentType +
", destination: " + this.destURI +
", origin: " + this.originURI +
- ", context: " + ((this.aContext) instanceof (Ci.nsIDOMHTMLElement)
- ? "<HTML Element>"
- : this.aContext) +
+ ", context: " + context +
", mime: " + this.aMimeTypeGuess +
", " + this.aExtra;
};
@@ -147,15 +147,15 @@ NormalRequest.prototype.isInternal = function() {
// "moz-nullprincipal" always shows up when using "document.location"?
// Not cross-site requests.
- if (this.aContentLocation.scheme == "resource"
- || this.aContentLocation.scheme == "about"
- || this.aContentLocation.scheme == "data"
- || this.aContentLocation.scheme == "chrome"
- || this.aContentLocation.scheme == "moz-icon"
- || this.aContentLocation.scheme == "moz-filedata"
- || this.aContentLocation.scheme == "blob"
- || this.aContentLocation.scheme == "wyciwyg"
- || this.aContentLocation.scheme == "javascript") {
+ if (this.aContentLocation.scheme === "resource" ||
+ this.aContentLocation.scheme === "about" ||
+ this.aContentLocation.scheme === "data" ||
+ this.aContentLocation.scheme === "chrome" ||
+ this.aContentLocation.scheme === "moz-icon" ||
+ this.aContentLocation.scheme === "moz-filedata" ||
+ this.aContentLocation.scheme === "blob" ||
+ this.aContentLocation.scheme === "wyciwyg" ||
+ this.aContentLocation.scheme === "javascript") {
Logger.info(Logger.TYPE_CONTENT,
"Allowing request with an internal destination.");
return true;
diff --git a/src/content/lib/ruleset.jsm b/src/content/lib/ruleset.jsm
index 9704e04..b753604 100644
--- a/src/content/lib/ruleset.jsm
+++ b/src/content/lib/ruleset.jsm
@@ -41,11 +41,7 @@ let {C} = importModule("lib/utils/constants");
//==============================================================================
function dprint(msg) {
- if (typeof print == "function") {
- print(msg);
- } else {
- Logger.info(Logger.TYPE_POLICY, msg);
- }
+ Logger.info(Logger.TYPE_POLICY, msg);
}
function dwarn(msg) {
@@ -80,30 +76,34 @@ exampleRawDataObj = {
};
*/
-function dump(arr,level) {
+/*
+// currently unused.
+function dump(arr, level=0) {
var dumped_text = "";
- if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = "";
- for(var j=0;j<level+1;j++) level_padding += " ";
+ for (let j = 0; j < level + 1; j++) {
+ level_padding += " ";
+ }
- if(typeof(arr) == 'object') { //Array/Hashes/Objects
- for(var item in arr) {
- var value = arr[item];
+ if (typeof arr === "object") { //Array/Hashes/Objects
+ for (let item in arr) {
+ let value = arr[item];
- if(typeof(value) == 'object') { //If it is an array,
+ if (typeof value === "object") { //If it is an array,
dumped_text += level_padding + "'" + item + "' ...\n";
- dumped_text += dump(value,level+1);
+ dumped_text += dump(value, level + 1);
} else {
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
}
}
} else { //Stings/Chars/Numbers etc.
- dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
+ dumped_text = "===>" + arr + "<===(" + typeof arr + ")";
}
return dumped_text;
}
+*/
//==============================================================================
// RawRuleset
@@ -115,11 +115,11 @@ function RawRuleset(jsonData) {
if (jsonData) {
this._fromJSON(jsonData);
}
- if (!this._entries["allow"]) {
- this._entries["allow"] = [];
+ if (!this._entries.allow) {
+ this._entries.allow = [];
}
- if (!this._entries["deny"]) {
- this._entries["deny"] = [];
+ if (!this._entries.deny) {
+ this._entries.deny = [];
}
}
@@ -132,24 +132,25 @@ RawRuleset.prototype = {
},
getAllowRuleCount : function() {
- return this._entries["allow"].length;
+ return this._entries.allow.length;
},
getDenyRuleCount : function() {
- return this._entries["deny"].length;
+ return this._entries.deny.length;
},
_addEntryHelper : function(entryPart, policy) {
- if (entryPart["h"]) {
- var rules = policy.addHost(entryPart["h"]).rules;
+ let rules;
+ if (entryPart.h) {
+ rules = policy.addHost(entryPart.h).rules;
} else {
rules = policy.rules;
}
- var r = rules.add(entryPart["s"], entryPart["port"]);
- if (entryPart["pathPre"]) {
- r.pathPre = entryPart["pathPre"];
- } else if (entryPart["pathRegex"]) {
- r.pathRegex = new RegExP(entryPart["pathRegex"]);
+ let r = rules.add(entryPart.s, entryPart.port);
+ if (entryPart.pathPre) {
+ r.pathPre = entryPart.pathPre;
+ } else if (entryPart.pathRegex) {
+ r.pathRegex = new RegExp(entryPart.pathRegex);
}
return [rules, r];
},
@@ -157,8 +158,8 @@ RawRuleset.prototype = {
_addEntryToRuleset : function(entry, ruleAction, policy) {
// TODO: add an "entryPart" format verifier/normalizer.
// notes: 'pathPre' => path prefix (must start with "/")
- var o = entry["o"];
- var d = entry["d"];
+ var o = entry.o;
+ var d = entry.d;
var rules, r;
//dprint("_addEntryToRuleset: " + o + " " + d + " " + ruleAction);
@@ -243,8 +244,8 @@ RawRuleset.prototype = {
},
// _removeEntryHelper : function(entryPart, policy) {
- // if (entryPart["h"]) {
- // var originEntry = policy.getHost(entryPart["h"]);
+ // if (entryPart.h) {
+ // var originEntry = policy.getHost(entryPart.h);
// if (!originEntry) {
// return null;
// }
@@ -252,43 +253,43 @@ RawRuleset.prototype = {
// } else {
// rules = policy.rules;
// }
- // return rules.get(entryPart["s"], entryPart["port"]);
+ // return rules.get(entryPart.s, entryPart.port);
// },
_removeEntryFromRuleset : function(entry, ruleAction, policy) {
// TODO: add an "entryPart" format verifier/normalizer.
// notes: 'pathPre' => path prefix (must start with "/")
- var o = entry["o"];
- var d = entry["d"];
+ var o = entry.o;
+ var d = entry.d;
var rules, r;
// TODO: refactor like done with _addEntryToRuleset
if (o && d) {
- if (o["h"]) {
- var originEntry = policy.getHost(o["h"]);
+ if (o.h) {
+ let originEntry = policy.getHost(o.h);
if (!originEntry) {
return;
}
- var rules = originEntry.rules;
+ rules = originEntry.rules;
} else {
rules = policy.rules;
}
- var r = rules.get(o["s"], o["port"]);
+ r = rules.get(o.s, o.port);
if (!r || !r.destinations) {
return;
}
- if (d["h"]) {
- var destEntry = r.destinations.getHost(d["h"]);
+ if (d.h) {
+ let destEntry = r.destinations.getHost(d.h);
if (!destEntry) {
return;
}
- var rules = destEntry.rules;
+ rules = destEntry.rules;
} else {
rules = r.destinations.rules;
}
- r = rules.get(d["s"], d["port"]);
+ r = rules.get(d.s, d.port);
if (!r) {
return;
}
@@ -306,16 +307,16 @@ RawRuleset.prototype = {
}
} else if (o && !d) {
- if (o["h"]) {
- var originEntry = policy.getHost(o["h"]);
+ if (o.h) {
+ let originEntry = policy.getHost(o.h);
if (!originEntry) {
return;
}
- var rules = originEntry.rules;
+ rules = originEntry.rules;
} else {
rules = policy.rules;
}
- var r = rules.get(o["s"], o["port"]);
+ r = rules.get(o.s, o.port);
if (!r) {
return;
}
@@ -332,16 +333,16 @@ RawRuleset.prototype = {
}
} else if (!o && d) {
- if (d["h"]) {
- var originEntry = policy.getHost(d["h"]);
- if (!originEntry) {
+ if (d.h) {
+ let destEntry = policy.getHost(d.h);
+ if (!destEntry) {
return;
}
- var rules = originEntry.rules;
+ rules = destEntry.rules;
} else {
rules = policy.rules;
}
- var r = rules.get(d["s"], d["port"]);
+ r = rules.get(d.s, d.port);
if (!r) {
return;
}
@@ -437,8 +438,8 @@ RawRuleset.prototype = {
throw "Invalid policy data: no 'version' key";
}
if (dataObj.metadata.version != 1) {
- throw "Wrong metadata version. Expected 1, was "
- + dataObj.metadata.version;
+ throw "Wrong metadata version. Expected 1, was " +
+ dataObj.metadata.version;
}
if (!("entries" in dataObj)) {
throw "Invalid policy data: no 'entries' key";
@@ -489,16 +490,18 @@ RuleIterator.prototype.next = function() {
//==============================================================================
function Rules() {
+ /**
+ * @type {Array<Rule>}
+ */
this._rules = [];
}
Rules.prototype = {
_rules : null,
- print : function(depth) {
- depth = depth || 0;
- for (var i = 0, item; item = this._rules[i]; i++) {
- item.print(depth);
+ print : function(depth = 0) {
+ for (let rule of this._rules) {
+ rule.print(depth);
}
},
@@ -579,15 +582,15 @@ Rule.prototype = {
destinations : null,
toString : function() {
- return "[Rule " + this.scheme + " " + this.port + " " + this.path + " "
- // TODO
+ return "[Rule " + this.scheme + " " + this.port + " " + this.path + " " +
+ // TODO
// + "originRuleAction:" + this.originRuleAction + " "
// + "destinationRuleAction:" + this.destinationRuleAction + " "
- + "allowOrigin:" + this.allowOrigin + " "
- + "denyOrigin:" + this.denyOrigin + " "
- + "allowDestination:" + this.allowDestination + " "
- + "denyDestination:" + this.denyDestination + " "
- + "]";
+ "allowOrigin:" + this.allowOrigin + " " +
+ "denyOrigin:" + this.denyOrigin + " " +
+ "allowDestination:" + this.allowDestination + " " +
+ "denyDestination:" + this.denyDestination + " " +
+ "]";
},
print : function(depth) {
@@ -662,7 +665,7 @@ Rule.prototype = {
//==============================================================================
function DomainEntry(name, fullName, higher) {
- if (typeof name != "string" && name !== null) {
+ if (typeof name !== "string" && name !== null) {
throw "Invalid type: DomainEntry name must be a string or null.";
}
this._name = name;
@@ -927,18 +930,24 @@ Ruleset.prototype = {
}
},
+ /**
+ * @param {nsIURI} origin
+ * @param {nsIURI} dest
+ * @return {Array<{length: 2, 0: Array<>, 1: Array<>}>}
+ */
check : function(origin, dest) {
var matchedAllowRules = [];
var matchedDenyRules = [];
+ var originHost, destHost;
try {
- var originHost = origin["host"];
+ originHost = origin.host;
} catch (e) {
- var originHost = '';
+ originHost = "";
}
try {
- var destHost = dest["host"];
+ destHost = dest.host;
} catch (e) {
- var destHost = '';
+ destHost = "";
}
//dprint("Checking origin rules and origin-to-destination rules.");
@@ -1048,7 +1057,7 @@ Ruleset.prototype = {
return [matchedAllowRules, matchedDenyRules];
}
-}
+};
/**
* @static
@@ -1056,18 +1065,18 @@ Ruleset.prototype = {
Ruleset._matchToRawRuleHelper = function(rawRule, originOrDest, entry, rule) {
rawRule[originOrDest] = {};
if (entry instanceof DomainEntry && entry.fullName) {
- rawRule[originOrDest]["h"] = entry.fullName;
+ rawRule[originOrDest].h = entry.fullName;
} else if (entry instanceof IPAddressEntry) {
- rawRule[originOrDest]["h"] = entry.address;
+ rawRule[originOrDest].h = entry.address;
}
if (rule.scheme) {
- rawRule[originOrDest]["s"] = rule.scheme;
+ rawRule[originOrDest].s = rule.scheme;
}
if (rule.port) {
- rawRule[originOrDest]["port"] = rule.port;
+ rawRule[originOrDest].port = rule.port;
}
// TODO: path
-}
+};
/**
* @static
@@ -1093,12 +1102,12 @@ Ruleset.matchToRawRule = function(match) {
Ruleset._matchToRawRuleHelper(rawRule, "o", entry, rule);
Ruleset._matchToRawRuleHelper(rawRule, "d", destEntry, destRule);
} else {
- throw "[matchToRawRule] Invalid match type: " + actionStr
- + " from match: " + match;
+ throw "[matchToRawRule] Invalid match type: " + actionStr +
+ " from match: " + match;
}
return rawRule;
-}
+};
/**
* @static
@@ -1107,43 +1116,43 @@ Ruleset._rawRuleToCanonicalStringHelper = function(rawRule, originOrDest, parts)
if (rawRule[originOrDest]) {
parts.push('"' + originOrDest + '":{');
var needComma = false;
- if (rawRule[originOrDest]["h"]) {
- parts.push('"h":"' + rawRule[originOrDest]["h"] + '"');
+ if (rawRule[originOrDest].h) {
+ parts.push('"h":"' + rawRule[originOrDest].h + '"');
needComma = true;
}
- if (rawRule[originOrDest]["port"]) {
+ if (rawRule[originOrDest].port) {
if (needComma) {
parts.push(',');
}
- parts.push('"port":"' + rawRule[originOrDest]["port"] + '"');
+ parts.push('"port":"' + rawRule[originOrDest].port + '"');
}
- if (rawRule[originOrDest]["s"]) {
+ if (rawRule[originOrDest].s) {
if (needComma) {
parts.push(',');
}
- parts.push('"s":"' + rawRule[originOrDest]["s"] + '"');
+ parts.push('"s":"' + rawRule[originOrDest].s + '"');
}
parts.push('}');
}
// TODO: pathPre and pathRegex (will need to escape strings)
parts.push('}');
return parts.join("");
-}
+};
Ruleset.rawRuleToCanonicalString = function(rawRule) {
var parts = ['{'];
- if (rawRule["d"]) {
+ if (rawRule.d) {
Ruleset._rawRuleToCanonicalStringHelper(rawRule, "d", parts);
}
- if (rawRule["d"] && rawRule["o"]) {
+ if (rawRule.d && rawRule.o) {
parts.push(',');
}
- if (rawRule["o"]) {
+ if (rawRule.o) {
Ruleset._rawRuleToCanonicalStringHelper(rawRule, "o", parts);
}
parts.push('}');
return parts.join("");
-}
+};
/**
* @static
diff --git a/src/content/lib/script-loader.jsm b/src/content/lib/script-loader.jsm
index 80be069..e8a978e 100644
--- a/src/content/lib/script-loader.jsm
+++ b/src/content/lib/script-loader.jsm
@@ -40,10 +40,10 @@ let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
// utilities
//==============================================================================
-const rpChromeContentURI = 'chrome://rpcontinued/content/';
+const RP_CHROME_CONTENT_URI = "chrome://rpcontinued/content/";
function getModuleURI(id) {
- return rpChromeContentURI + id + ".jsm";
+ return RP_CHROME_CONTENT_URI + id + ".jsm";
}
/**
@@ -59,7 +59,6 @@ function logSevereError(msg, e) {
//==============================================================================
var ScriptLoader = (function() {
-
let importedModuleURIs = {};
// URIs in that variable will not be unloaded
diff --git a/src/content/lib/subscription.jsm b/src/content/lib/subscription.jsm
index 68858fa..64cfb83 100644
--- a/src/content/lib/subscription.jsm
+++ b/src/content/lib/subscription.jsm
@@ -65,22 +65,17 @@ const SUBSCRIPTION_UPDATE_FAILURE = 'FAILURE';
function setTimeout(func, delay) {
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- var event = {notify: function() { func() }};
+ var event = {
+ notify: function() {
+ func();
+ }
+ };
timer.initWithCallback(event, delay, Ci.nsITimer.TYPE_ONE_SHOT);
return timer;
}
-
function dprint(msg) {
- if (typeof print == "function") {
- print(msg);
- } else {
- Logger.info(Logger.TYPE_INTERNAL, msg);
- }
-}
-
-function dwarn(msg) {
- Logger.warning(Logger.TYPE_INTERNAL, msg);
+ Logger.info(Logger.TYPE_INTERNAL, msg);
}
//==============================================================================
@@ -100,8 +95,8 @@ function UserSubscriptions() {
jsonData = FileUtil.fileToString(userSubsFile);
}
this._data = JSON.parse(jsonData);
- if (!this._data['lists']) {
- this._data['lists'] = {
+ if (!this._data.lists) {
+ this._data.lists = {
'official' : {
'subscriptions' : {
'allow_embedded' : {},
@@ -114,7 +109,7 @@ function UserSubscriptions() {
}
};
}
- this._lists = this._data['lists'];
+ this._lists = this._data.lists;
}
UserSubscriptions.prototype = {
@@ -129,18 +124,18 @@ UserSubscriptions.prototype = {
},
getSubscriptionInfo : function(defaultPolicy) {
- var lists = this._data['lists'];
+ var lists = this._data.lists;
var result = {};
for (var listName in lists) {
- if (!lists[listName]['subscriptions']) {
+ if (!lists[listName].subscriptions) {
continue;
}
result[listName] = {};
- for (var subName in lists[listName]['subscriptions']) {
- if (defaultPolicy == 'allow' && subName.indexOf('allow_') == 0) {
+ for (let subName in lists[listName].subscriptions) {
+ if (defaultPolicy === "allow" && subName.indexOf("allow_") === 0) {
continue;
}
- if (defaultPolicy == 'deny' && subName.indexOf('deny_') == 0) {
+ if (defaultPolicy === "deny" && subName.indexOf("deny_") === 0) {
continue;
}
result[listName][subName] = null;
@@ -150,22 +145,22 @@ UserSubscriptions.prototype = {
},
addSubscription : function(listName, subName) {
- var lists = this._data['lists'];
+ var lists = this._data.lists;
if (!lists[listName]) {
lists[listName] = {};
}
- if (!lists[listName]['subscriptions']) {
- lists[listName]['subscriptions'] = {};
+ if (!lists[listName].subscriptions) {
+ lists[listName].subscriptions = {};
}
- lists[listName]['subscriptions'][subName] = {};
+ lists[listName].subscriptions[subName] = {};
this.save();
},
removeSubscription : function(listName, subName) {
- var lists = this._data['lists'];
- if (lists[listName] && lists[listName]['subscriptions'] &&
- lists[listName]['subscriptions'][subName]) {
- delete lists[listName]['subscriptions'][subName];
+ var lists = this._data.lists;
+ if (lists[listName] && lists[listName].subscriptions &&
+ lists[listName].subscriptions[subName]) {
+ delete lists[listName].subscriptions[subName];
}
this.save();
},
@@ -183,29 +178,29 @@ UserSubscriptions.prototype = {
dprint('Recording done: ' + listName + ' ' + subName);
if (subName) {
updateResults[listName][subName] = result;
- var list = updatingLists[listName];
+ let list = updatingLists[listName];
delete list[subName];
- for (var i in list) {
- return;
+ for (let i in list) {
+ return; // What's that??
}
}
delete updatingLists[listName];
- for (var i in updatingLists) {
- return;
+ for (let i in updatingLists) {
+ return; // What's that??
}
setTimeout(function () { callback(updateResults); }, 0);
}
var listCount = 0;
for (var listName in serials) {
- if (!this._lists[listName] || !this._lists[listName]['subscriptions']) {
- dprint('Skipping update of unsubscribed list: ' + listName);
+ if (!this._lists[listName] || !this._lists[listName].subscriptions) {
+ dprint("Skipping update of unsubscribed list: " + listName);
continue;
}
let updateSubs = {};
var subCount = 0;
- for (var subName in serials[listName]) {
- if (!this._lists[listName]['subscriptions'][subName]) {
+ for (let subName in serials[listName]) {
+ if (!this._lists[listName].subscriptions[subName]) {
dprint('Skipping update of unsubscribed subscription: ' + listName + ' ' + subName);
continue;
}
@@ -224,7 +219,7 @@ UserSubscriptions.prototype = {
dprint('Skipping list with no subscriptions: ' + listName);
continue;
}
- var url = this._lists[listName]['url'];
+ var url = this._lists[listName].url;
if (!url) {
url = DEFAULT_SUBSCRIPTION_LIST_URL_BASE + listName + '.json';
}
@@ -234,7 +229,7 @@ UserSubscriptions.prototype = {
}
var list = new SubscriptionList(listName, url);
updatingLists[listName] = {};
- for (var subName in updateSubs) {
+ for (let subName in updateSubs) {
dprint('Will update subscription: ' + listName + ' ' + subName);
updatingLists[listName][subName] = true;
}
@@ -260,7 +255,7 @@ UserSubscriptions.prototype = {
dprint('Failed to update list: ' + list.toString() + ': ' + error);
updateResults[listName] = false;
recordDone(list._name);
- }
+ };
listCount++;
dprint('Will update list: ' + listName);
@@ -274,6 +269,9 @@ UserSubscriptions.prototype = {
}
};
+//==============================================================================
+// SubscriptionList
+//==============================================================================
/**
* Represents a list of available subscriptions. Any actual subscription belongs
@@ -326,15 +324,16 @@ SubscriptionList.prototype = {
updateSubscriptions : function (userSubs, successCallback, errorCallback) {
for (var subName in userSubs) {
+ let sub;
try {
var serial = this.getSubscriptionSerial(subName);
dprint('Current serial for ' + this._name + ' ' + subName + ': ' +
- userSubs[subName]['serial']);
+ userSubs[subName].serial);
dprint('Available serial for ' + this._name + ' ' + subName + ': ' +
serial);
var subUrl = this.getSubscriptionUrl(subName);
- var sub = new Subscription(this._name, subName, subUrl);
- if (serial > userSubs[subName]['serial']) {
+ sub = new Subscription(this._name, subName, subUrl);
+ if (serial > userSubs[subName].serial) {
sub.update(successCallback, errorCallback);
} else {
dprint('No update needed for ' + this._name + ' ' + subName);
@@ -345,28 +344,33 @@ SubscriptionList.prototype = {
}
} catch (e) {
let curSub = sub;
- setTimeout(function () { errorCallback(curSub, e.toString()); }, 0);
+ setTimeout(function () {
+ errorCallback(curSub, e.toString());
+ }, 0);
}
}
},
// getSubscriptionNames : function () {
// var names = [];
-// for (var subName in this._data['subscriptions']) {
+// for (var subName in this._data.subscriptions) {
// names.push(subName);
// }
// return names;
// },
getSubscriptionSerial : function (subName) {
- return this._data['subscriptions'][subName]['serial'];
+ return this._data.subscriptions[subName].serial;
},
getSubscriptionUrl : function (subName) {
- return this._data['subscriptions'][subName]['url'];
+ return this._data.subscriptions[subName].url;
}
};
+//==============================================================================
+// Subscription
+//==============================================================================
/**
* Represents a particular subscription policy available through a given
@@ -412,16 +416,21 @@ Subscription.prototype = {
// Make sure there's a ['metadata']['serial'] key as a way of sanity
// checking the parsed JSON as well as enforcing the use of serial
// numbers in subscription rulesets.
+ let serial;
try {
- var serial = self._data['metadata']['serial'];
+ serial = self._data.metadata.serial;
} catch (e) {
- var error = 'Ruleset has no serial number';
- setTimeout(function () { errorCallback(self, error); }, 0);
+ let error = 'Ruleset has no serial number';
+ setTimeout(function () {
+ errorCallback(self, error);
+ }, 0);
return;
}
if (typeof serial != 'number' || serial % 1 != 0) {
- var error = 'Ruleset has invalid serial number: ' + serial;
- setTimeout(function () { errorCallback(self, error); }, 0);
+ let error = 'Ruleset has invalid serial number: ' + serial;
+ setTimeout(function () {
+ errorCallback(self, error);
+ }, 0);
return;
}
// The rest of the sanity checking is done by RawRuleset().
@@ -439,14 +448,16 @@ Subscription.prototype = {
Services.obs.notifyObservers(null, SUBSCRIPTION_UPDATED_TOPIC,
JSON.stringify(subInfo));
setTimeout(function () {
- successCallback(self, SUBSCRIPTION_UPDATE_SUCCESS);
+ successCallback(self, SUBSCRIPTION_UPDATE_SUCCESS);
}, 0);
} catch (e) {
setTimeout(function () { errorCallback(self, e.toString()); }, 0);
}
};
req.onerror = function (event) {
- setTimeout(function () { errorCallback(self, req.statusText); }, 0);
+ setTimeout(function () {
+ errorCallback(self, req.statusText);
+ }, 0);
};
req.open('GET', this._url);
req.send(null);
diff --git a/src/content/lib/utils.jsm b/src/content/lib/utils.jsm
index ab92a2d..7fe2207 100644
--- a/src/content/lib/utils.jsm
+++ b/src/content/lib/utils.jsm
@@ -97,9 +97,13 @@ var Utils = (function() {
* @param {Object} object
* @param {...string} properties
*/
+ // FIXME: Re-enable (W119) when JSHint issue #2785 is fixed.
+ // https://github.com/jshint/jshint/issues/2785
+ /* jshint -W119 */
self.getObjectPath = function(object, ...properties) {
return properties.reduce(self.getObjectProperty, object);
};
+ /* jshint +W119 */
/**
* @private
@@ -132,7 +136,7 @@ var Utils = (function() {
aModuleScope.internal = aModuleScope.internal || {};
function sealInternal() {
delete aModuleScope.internal;
- };
+ }
ProcessEnvironment.addStartupFunction(Environment.LEVELS.ESSENTIAL,
sealInternal);
return aModuleScope.internal;
diff --git a/src/content/lib/utils/domains.jsm b/src/content/lib/utils/domains.jsm
index 2630d90..6413738 100644
--- a/src/content/lib/utils/domains.jsm
+++ b/src/content/lib/utils/domains.jsm
@@ -63,7 +63,8 @@ DomainUtil.getIdentifier = function(uri, level) {
var identifier;
var identifierGettingFunctionName;
- // We only have one identifier that we're using now: the pre-path / LEVEL_SOP.
+ // We only have one identifier that we're using now:
+ // the pre-path / LEVEL_SOP.
// TODO: figure out how we want to rename this function and clean up the
// unused parts.
level = this.LEVEL_SOP;
@@ -79,9 +80,8 @@ DomainUtil.getIdentifier = function(uri, level) {
identifierGettingFunctionName = "getPrePath";
break;
default :
- throw "Invalid identifier level specified in DomainUtil.getIdentifier(): "
- + level;
- break;
+ throw "Invalid identifier level specified " +
+ "in DomainUtil.getIdentifier(): " + level;
}
try {
@@ -99,7 +99,7 @@ DomainUtil.getIdentifier = function(uri, level) {
return "file://";
} else if (uri.indexOf("data:") == 0) {
// Format: data:[<MIME-type>][;charset=<encoding>][;base64],<data>
- var identifier = uri.split(",")[0];
+ identifier = uri.split(",")[0];
return identifier.split(";")[0];
}
Logger.info(Logger.TYPE_INTERNAL, "Unable to getIdentifier from uri " +
@@ -132,7 +132,7 @@ DomainUtil.getHost = function(uri) {
DomainUtil.uriObjHasHost = function(aUriObj) {
try {
// simply access the host.
- aUriObj.host;
+ aUriObj.host; // jshint ignore:line
return true;
} catch (e) {
// it's an URI without host
@@ -145,10 +145,9 @@ DomainUtil.uriObjHasHost = function(aUriObj) {
* automatically convert ACE formatting to UTF8 for IDNs in the various
* attributes of the object that are available.
*
- * @param {String}
- * uri The uri.
+ * @param {String} uri The uri.
* @return {nsIURI} The nsIURI object created from the uri, or throws an
- * exception if it is an invalid uri.
+ * exception if it is an invalid uri.
*/
DomainUtil.getUriObject = function(uri) {
// fixme: if `uri` is relative, `newURI()` throws NS_ERROR_MALFORMED_URI.
@@ -158,8 +157,8 @@ DomainUtil.getUriObject = function(uri) {
try {
return Services.io.newURI(uri, null, null);
} catch (e) {
- var msg = "DomainUtil.getUriObject exception on uri <" + uri + "> "
- + ". Exception was: " + e;
+ var msg = "DomainUtil.getUriObject exception on uri <" + uri + "> " +
+ ". Exception was: " + e;
Logger.info(Logger.TYPE_INTERNAL, msg);
throw e;
}
@@ -168,8 +167,7 @@ DomainUtil.getUriObject = function(uri) {
/**
* Determines whether a uri string represents a valid uri.
*
- * @param {String}
- * uri The uri.
+ * @param {String} uri The uri.
* @return {boolean} True if the uri is valid, false otherwise.
*/
DomainUtil.isValidUri = function(uri) {
@@ -184,8 +182,7 @@ DomainUtil.isValidUri = function(uri) {
/**
* Returns the domain from a uri string.
*
- * @param {String}
- * uri The uri.
+ * @param {String} uri The uri.
* @return {String} The domain of the uri.
*/
DomainUtil.getBaseDomain = function(uri) {
@@ -221,20 +218,19 @@ DomainUtil.getBaseDomain = function(uri) {
*/
DomainUtil.isIPAddress = function(host) {
try {
- var baseDomain = Services.eTLD.getBaseDomainFromHost(host, 0);
+ Services.eTLD.getBaseDomainFromHost(host, 0);
} catch (e) {
if (e.name == "NS_ERROR_HOST_IS_IP_ADDRESS") {
return true;
}
}
return false;
-}
+};
/**
* Returns the path from a uri string.
*
- * @param {String}
- * uri The uri.
+ * @param {String} uri The uri.
* @return {String} The path of the uri.
*/
DomainUtil.getPath = function(uri) {
@@ -242,12 +238,11 @@ DomainUtil.getPath = function(uri) {
};
/**
- * Returns the prePath from a uri string. Note that this will return a prePath in
- * UTF8 format for all IDNs, even if the uri passed to the function is ACE
- * formatted.
+ * Returns the prePath from a uri string. Note that this will return
+ * a prePath in UTF8 format for all IDNs, even if the uri passed to
+ * the function is ACE formatted.
*
- * @param {String}
- * uri The uri.
+ * @param {String} uri The uri.
* @return {String} The prePath of the uri.
*/
DomainUtil.getPrePath = function(uri) {
@@ -262,14 +257,13 @@ DomainUtil.stripFragment = function(uri) {
/**
* Gets the relevant pieces out of a meta refresh or header refresh string.
*
- * @param {String}
- * refreshString The original content of a refresh header or meta tag.
+ * @param {String} refreshString The original content of a refresh
+ * header or meta tag.
* @return {Object} The delay in seconds and the url to refresh to.
- * The url may be an empty string if the current url should be
- * refreshed.
- * @throws Generic
- * exception if the refreshString has an invalid format, including if
- * the seconds can't be parsed as a float.
+ * The url may be an empty string if the current url should be
+ * refreshed.
+ * @throws Generic exception if the refreshString has an invalid format,
+ * including if the seconds can't be parsed as a float.
*/
DomainUtil.parseRefresh = function(refreshString) {
var parts = /^\s*(\S*?)\s*(;\s*url\s*=\s*(.*?)\s*)?$/i.exec(refreshString);
@@ -290,15 +284,14 @@ DomainUtil.parseRefresh = function(refreshString) {
}
}
return {delay: delay, destURI: url};
-}
+};
/**
* Adds a path of "/" to the uri if it doesn't have one. That is,
- * "http://127.0.0.1" is returned as "http://127.0.0.1/". Will return the origin
- * uri if the provided one is not valid.
+ * "http://127.0.0.1" is returned as "http://127.0.0.1/". Will return
+ * the origin uri if the provided one is not valid.
*
- * @param {String}
- * uri
+ * @param {String} uri
* @return {String}
*/
DomainUtil.ensureUriHasPath = function(uri) {
@@ -307,18 +300,18 @@ DomainUtil.ensureUriHasPath = function(uri) {
} catch (e) {
return uri;
}
-}
+};
/**
- * Returns the same uri but makes sure that it's UTF8 formatted instead of ACE
- * formatted if it's an IDN that Mozilla supports displaying in UTF8 format. See
- * http://www.mozilla.org/projects/security/tld-idn-policy-list.html for more
- * info.
+ * Returns the same uri but makes sure that it's UTF8 formatted
+ * instead of ACE formatted if it's an IDN that Mozilla supports
+ * displaying in UTF8 format. See
+ * http://www.mozilla.org/projects/security/tld-idn-policy-list.html
+ * for more info.
*
- * @param {String}
- * uri The uri.
+ * @param {String} uri The uri.
* @return {nsIURI} The same uri but with UTF8 formatting if the original uri
- * was ACE formatted.
+ * was ACE formatted.
*/
DomainUtil.formatIDNUri = function(uri) {
// Throws an exception if uri is invalid. This is almost the same as the
@@ -335,10 +328,8 @@ DomainUtil.formatIDNUri = function(uri) {
* (starts with a slash), a protocol relative path (starts with two slashes),
* or is relative to the originUri path.
*
- * @param {String}
- * originUri
- * @param {String}
- * destPath
+ * @param {String} originUri
+ * @param {String} destPath
* @return {String}
*/
DomainUtil.determineRedirectUri = function(originUri, destPath) {
@@ -348,13 +339,12 @@ DomainUtil.determineRedirectUri = function(originUri, destPath) {
newUri.init(urlType, 0, destPath, null, baseUri);
var resolvedUri = newUri.QueryInterface(Ci.nsIURI);
return resolvedUri.spec;
-}
+};
/**
* Determines whether a URI uses the standard port for its scheme.
*
- * @param {nsIURI}
- * uri
+ * @param {nsIURI} uri
* @return {Boolean}
*/
DomainUtil.hasStandardPort = function(uri) {
diff --git a/src/content/lib/utils/files.jsm b/src/content/lib/utils/files.jsm
index fdf5297..8cf4127 100644
--- a/src/content/lib/utils/files.jsm
+++ b/src/content/lib/utils/files.jsm
@@ -47,8 +47,9 @@ function getOctalInt() {
}
return result;
}
-const octal444 = getOctalInt(4,4,4); // octal: 0444
-const octal700 = getOctalInt(7,0,0); // octal: 0700
+
+const OCTAL_444 = getOctalInt(4, 4, 4); // octal: 0444
+const OCTAL_700 = getOctalInt(7, 0, 0); // octal: 0700
const REQUESTPOLICY_DIR = "requestpolicy";
@@ -67,7 +68,7 @@ var FileUtil = {
fileToArray : function(file) {
var stream = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
- stream.init(file, 0x01, octal444, 0);
+ stream.init(file, 0x01, OCTAL_444, 0);
stream.QueryInterface(Ci.nsILineInputStream);
var line = {}, lines = [], hasmore;
do {
@@ -101,7 +102,7 @@ var FileUtil = {
//}
var stream = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
- stream.init(file, 0x01, octal444, 0);
+ stream.init(file, 0x01, OCTAL_444, 0);
stream.QueryInterface(Ci.nsILineInputStream);
var cstream = Cc["@mozilla.org/intl/converter-input-stream;1"].
@@ -183,25 +184,25 @@ var FileUtil = {
var file = profileDir.clone();
file.appendRelativePath(REQUESTPOLICY_DIR);
if(!file.exists()) {
- file.create(Ci.nsIFile.DIRECTORY_TYPE, octal700);
+ file.create(Ci.nsIFile.DIRECTORY_TYPE, OCTAL_700);
}
if (subdir1) {
file.appendRelativePath(subdir1);
if(!file.exists()) {
- file.create(Ci.nsIFile.DIRECTORY_TYPE, octal700);
+ file.create(Ci.nsIFile.DIRECTORY_TYPE, OCTAL_700);
}
if (subdir2) {
file.appendRelativePath(subdir2);
if(!file.exists()) {
- file.create(Ci.nsIFile.DIRECTORY_TYPE, octal700);
+ file.create(Ci.nsIFile.DIRECTORY_TYPE, OCTAL_700);
}
if (subdir3) {
file.appendRelativePath(subdir3);
if(!file.exists()) {
- file.create(Ci.nsIFile.DIRECTORY_TYPE, octal700);
+ file.create(Ci.nsIFile.DIRECTORY_TYPE, OCTAL_700);
}
}
}
diff --git a/src/content/lib/utils/strings.jsm b/src/content/lib/utils/strings.jsm
index de4c3a8..5227421 100644
--- a/src/content/lib/utils/strings.jsm
+++ b/src/content/lib/utils/strings.jsm
@@ -44,11 +44,11 @@ var StringUtils = (function() {
return loadPropertiesFile(
"chrome://rpcontinued/locale/requestpolicy.properties");
});
+
// from https://developer.mozilla.org/en-US/Add-ons/
// How_to_convert_an_overlay_extension_to_restartless
// #Step_10.3A_Bypass_cache_when_loading_properties_files
- function loadPropertiesFile(path)
- {
+ function loadPropertiesFile(path) {
/* HACK: The string bundle cache is cleared on addon shutdown, however it
* doesn't appear to do so reliably. Errors can erratically happen on next
* load of the same file in certain instances. (at minimum, when strings are
diff --git a/src/content/lib/utils/windows.jsm b/src/content/lib/utils/windows.jsm
index 588e8ce..d5ea38d 100644
--- a/src/content/lib/utils/windows.jsm
+++ b/src/content/lib/utils/windows.jsm
@@ -85,25 +85,25 @@ var WindowUtils = (function() {
let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/" +
"PrivateBrowsingUtils.jsm", {});
- return (function(aWindow) {
- return PrivateBrowsingUtils.isWindowPrivate(aWindow)
- });
+ return function (aWindow) {
+ return PrivateBrowsingUtils.isWindowPrivate(aWindow);
+ };
} catch(e) {
// pre Firefox 20
try {
let pbs = Cc["@mozilla.org/privatebrowsing;1"]
.getService(Ci.nsIPrivateBrowsingService);
- return (function(aWindow) {
+ return function(aWindow) {
return pbs.privateBrowsingEnabled;
- });
+ };
} catch(e) {
Components.utils.reportError(e);
// It's uncertain if private browsing is possible at all, so assume
// that Private Browsing is not possible.
- return (function(aWindow) {
+ return function(aWindow) {
return true;
- });
+ };
}
}
}());
diff --git a/src/content/lib/utils/xul.jsm b/src/content/lib/utils/xul.jsm
index 6b58680..20912be 100644
--- a/src/content/lib/utils/xul.jsm
+++ b/src/content/lib/utils/xul.jsm
@@ -75,7 +75,7 @@ var xulTrees = XULUtils.xulTrees = {};
// Ensure the Element Spec has an ID attribute.
if (!aElementSpec.attributes.hasOwnProperty("id")) {
- aElementSpec.attributes.id = "rpc-autoid-" + (nextID++);
+ aElementSpec.attributes.id = "rpc-autoid-" + nextID++;
//Logger.dump("Automatically created ID '" + aElementSpec.attributes.id +
// "' for element <" + aElementSpec.tag + ">");
}
@@ -103,7 +103,8 @@ function recursivelyGetAllElementSpecs(aElementSpecList) {
// Add all children recursively.
if (elementSpec.hasOwnProperty("children")) {
- let allChildrenSpecs = recursivelyGetAllElementSpecs(elementSpec.children)
+ let allChildrenSpecs = recursivelyGetAllElementSpecs(
+ elementSpec.children);
allElementSpecs = allElementSpecs.concat(allChildrenSpecs);
}
}
@@ -282,13 +283,13 @@ function recursivelyAddXULElements(aDocument, aElementSpecList,
}
parentElement.appendChild(newElement);
}
-};
+}
XULUtils.addTreeElementsToWindow = function(aWin, aTreeName) {
if (xulTrees.hasOwnProperty(aTreeName)) {
recursivelyAddXULElements(aWin.document, xulTrees[aTreeName]);
}
-}
+};
/**
* Return a list of the IDs of the specified tree's root elements.
@@ -325,4 +326,4 @@ XULUtils.removeTreeElementsFromWindow = function(aWin, aTreeName) {
node.parentNode.removeChild(node);
}
}
-}
+};
diff --git a/src/content/main/about-uri.jsm b/src/content/main/about-uri.jsm
index fef9aeb..6aa9f7e 100644
--- a/src/content/main/about-uri.jsm
+++ b/src/content/main/about-uri.jsm
@@ -39,7 +39,7 @@ let {Utils} = importModule("lib/utils");
// utilities, constants
//==============================================================================
-var filenames = {
+const FILENAMES = {
"basicprefs": "basicprefs.html",
"advancedprefs": "advancedprefs.html",
"yourpolicy": "yourpolicy.html",
@@ -55,10 +55,10 @@ function getURI(aURI) {
if (index >= 0 && aURI.path.length > index) {
id = aURI.path.substr(index+1);
}
- if (!id || !(id in filenames)) {
+ if (!id || !(id in FILENAMES)) {
id = "basicprefs";
}
- return "chrome://rpcontinued/content/settings/" + filenames[id];
+ return "chrome://rpcontinued/content/settings/" + FILENAMES[id];
}
//==============================================================================
diff --git a/src/content/main/content-policy.jsm b/src/content/main/content-policy.jsm
index 7a816e9..0bffa88 100644
--- a/src/content/main/content-policy.jsm
+++ b/src/content/main/content-policy.jsm
@@ -124,7 +124,10 @@ var PolicyImplementation = (function() {
// Actually create the final function, as it is described
// above.
+ // FIXME: Re-enable (W119) when JSHint issue #2785 is fixed.
+ /* jshint -W119 */
self.shouldLoad = () => finalReturnValue;
+ /* jshint +W119 */
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
let catMan = Utils.categoryManager;
@@ -168,7 +171,10 @@ var PolicyImplementation = (function() {
// aContext, aMimeTypeGuess, aExtra, aRequestPrincipal);
};
- self.shouldProcess = (() => C.CP_OK);
+ // FIXME: Re-enable (W119) when JSHint issue #2785 is fixed.
+ /* jshint -W119 */
+ self.shouldProcess = () => C.CP_OK;
+ /* jshint +W119 */
//----------------------------------------------------------------------------
// nsIFactory interface implementation
diff --git a/src/content/main/default-pref-handler.js b/src/content/main/default-pref-handler.js
index fc51182..d42627b 100644
--- a/src/content/main/default-pref-handler.js
+++ b/src/content/main/default-pref-handler.js
@@ -55,8 +55,9 @@ let prefInitFunctions = {
return branch.getBoolPref(prefName);
case 0:
- default:
// PREF_INVALID
+ /* falls through */
+ default:
return undefined;
}
},
diff --git a/src/content/main/pref-manager.jsm b/src/content/main/pref-manager.jsm
index b4a5a7c..b0523ec 100644
--- a/src/content/main/pref-manager.jsm
+++ b/src/content/main/pref-manager.jsm
@@ -60,7 +60,6 @@ XPCOMUtils.defineLazyGetter(globalScope, "rootPrefBranch", function() {
var PrefManager = (function() {
let self = {};
-
// TODO: move to bootstrap.js
function handleUninstallOrDisable() {
var resetLinkPrefetch = rpPrefBranch.getBoolPref(
diff --git a/src/content/main/requestpolicy-service.jsm b/src/content/main/requestpolicy-service.jsm
index ec7f7ba..c93d5d8 100644
--- a/src/content/main/requestpolicy-service.jsm
+++ b/src/content/main/requestpolicy-service.jsm
@@ -103,12 +103,14 @@ var rpService = (function() {
var wm = Cc['@mozilla.org/appshell/window-mediator;1'].
getService(Ci.nsIWindowMediator);
var windowtype = 'navigator:browser';
- var mostRecentWindow = wm.getMostRecentWindow(windowtype);
+ var mostRecentWindow = wm.getMostRecentWindow(windowtype);
// the gBrowser object of the firefox window
var _gBrowser = mostRecentWindow.getBrowser();
- if (typeof(_gBrowser.addTab) != "function") return;
+ if (typeof _gBrowser.addTab !== "function") {
+ return;
+ }
_gBrowser.selectedTab = _gBrowser.addTab(url);
@@ -173,7 +175,7 @@ var rpService = (function() {
// the gBrowser object of the firefox window
var _gBrowser = mostRecentWindow.getBrowser();
- if (typeof(_gBrowser.addTab) !== "function") {
+ if (typeof _gBrowser.addTab !== "function") {
return false;
}
@@ -312,7 +314,7 @@ var rpService = (function() {
let updateCompleted = function(result) {
Logger.info(Logger.TYPE_INTERNAL,
'Subscription update completed: ' + result);
- }
+ };
subscriptions.update(updateCompleted, serials);
}
break;
diff --git a/src/content/main/window-manager.listener.js b/src/content/main/window-manager.listener.js
index 714fa0c..7adb5a0 100644
--- a/src/content/main/window-manager.listener.js
+++ b/src/content/main/window-manager.listener.js
@@ -40,7 +40,7 @@ var WindowListener = (function() {
let addEvLis = function(eventName, winID) {
- if ((typeof listeners[winID]) !== 'undefined' &&
+ if (typeof listeners[winID] !== "undefined" &&
listeners[winID][eventName] !== null) {
listeners[winID].window.addEventListener(eventName,
listeners[winID][eventName],
@@ -65,6 +65,18 @@ var WindowListener = (function() {
+ // external functions to be called on "load" or "unload" events
+ let externalLoadFunction = null;
+ let externalUnloadFunction = null;
+ self.setLoadFunction = function(f) {
+ externalLoadFunction = f;
+ };
+ self.setUnloadFunction = function(f) {
+ externalUnloadFunction = f;
+ };
+
+
+
let addEventListenersToWindow = function(window) {
let winID = nextWinID++;
@@ -119,18 +131,6 @@ var WindowListener = (function() {
}
-
- // external functions to be called on "load" or "unload" events
- let externalLoadFunction = null;
- let externalUnloadFunction = null;
- self.setLoadFunction = function(f) {
- externalLoadFunction = f;
- };
- self.setUnloadFunction = function(f) {
- externalUnloadFunction = f;
- };
-
-
let listening = false;
self.startListening = function() {
if (listening === false) {
diff --git a/src/content/ui/frame.blocked-content.js b/src/content/ui/frame.blocked-content.js
index 15772cd..5ecc69d 100644
--- a/src/content/ui/frame.blocked-content.js
+++ b/src/content/ui/frame.blocked-content.js
@@ -27,30 +27,30 @@ var ManagerForBlockedContent = (function() {
//============================================================================
- let missingImageDataUri = "data:image/png;base64,"
- + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c"
- + "6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0"
- + "SU1FB9gMFRANL5LXnioAAAJWSURBVDjLnZI/ixtXFMV/972ZNzPSrmTtalex"
- + "lsWBGMfEYOzaVciXyKdIkW/hFKnS22WafIDUxk0g2AQSgm0csIPWK42ktaSR"
- + "NPP+pRBK5SLOqS7cew7ccw4xxrPJ+8XdHx4+7AE8e3Cj++zLm71fvrqT8x+Q"
- + "AK35dJr2n/x89urTa+eDm/cS+eI2y3eT+Lx/bt8u1vNqfDH++teXdk/6ThAf"
- + "UUBIgL9ku75z/8WL7LOlhXIGJ0Pyw75wMcnGv//xSQ2DH4ddu9k01dXWsWzc"
- + "ofhYaiiViLjiWi9UWQa1gzcjWF7hgfzzW5ydnXB62JLjg0PTLfJertNepnQS"
- + "IA+gE4Cs03UuNYYQYP4e5jPogmSG9vA6rrjC+0AxN2i5Qk0DpXVJhCQB0EVR"
- + "rzqdFgB1DZfvCDHixiV2NqO6LHHKIKnQMoaWbFBgIrQVgIXaDc+JCHgP5QRZ"
- + "r4jzGWFbo6yncRYviiiQKUhBRch3Lyix4bgPWsAkcDkmZAV2OiE0DaI1WoES"
- + "hRKF3sWnmt01pFBnJydEpZDEwHSGt47lYsls43AIXjTWV9R1Qx0DGahqLyAh"
- + "bqrj0/ib0nRzXNoyCo0Kkor2llV0eKOwdUMg4pSQA7JPQXvnJv1B+GlwOvrG"
- + "laXB6fV2lb5t6qOtike56DSJgYDGBQcOAsQAfueBMeHR48fhadb1j/58HWAR"
- + "dt6yBv7+/vpBe2o5OogxlcaKdt5aKCNsk309W0WxKQjmQ33/9mJVAdWHdmo/"
- + "tNvtRZIkfCz+ZQwGg6rT6Zj/LTAajTbD4bD5WIF/AAseEisPFO8uAAAAAElF"
- + "TkSuQmCC";
+ const MISSING_IMAGE_DATA_URI = "data:image/png;base64," +
+ "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c" +
+ "6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0" +
+ "SU1FB9gMFRANL5LXnioAAAJWSURBVDjLnZI/ixtXFMV/972ZNzPSrmTtalex" +
+ "lsWBGMfEYOzaVciXyKdIkW/hFKnS22WafIDUxk0g2AQSgm0csIPWK42ktaSR" +
+ "NPP+pRBK5SLOqS7cew7ccw4xxrPJ+8XdHx4+7AE8e3Cj++zLm71fvrqT8x+Q" +
+ "AK35dJr2n/x89urTa+eDm/cS+eI2y3eT+Lx/bt8u1vNqfDH++teXdk/6ThAf" +
+ "UUBIgL9ku75z/8WL7LOlhXIGJ0Pyw75wMcnGv//xSQ2DH4ddu9k01dXWsWzc" +
+ "ofhYaiiViLjiWi9UWQa1gzcjWF7hgfzzW5ydnXB62JLjg0PTLfJertNepnQS" +
+ "IA+gE4Cs03UuNYYQYP4e5jPogmSG9vA6rrjC+0AxN2i5Qk0DpXVJhCQB0EVR" +
+ "rzqdFgB1DZfvCDHixiV2NqO6LHHKIKnQMoaWbFBgIrQVgIXaDc+JCHgP5QRZ" +
+ "r4jzGWFbo6yncRYviiiQKUhBRch3Lyix4bgPWsAkcDkmZAV2OiE0DaI1WoES" +
+ "hRKF3sWnmt01pFBnJydEpZDEwHSGt47lYsls43AIXjTWV9R1Qx0DGahqLyAh" +
+ "bqrj0/ib0nRzXNoyCo0Kkor2llV0eKOwdUMg4pSQA7JPQXvnJv1B+GlwOvrG" +
+ "laXB6fV2lb5t6qOtike56DSJgYDGBQcOAsQAfueBMeHR48fhadb1j/58HWAR" +
+ "dt6yBv7+/vpBe2o5OogxlcaKdt5aKCNsk309W0WxKQjmQ33/9mJVAdWHdmo/" +
+ "tNvtRZIkfCz+ZQwGg6rT6Zj/LTAajTbD4bD5WIF/AAseEisPFO8uAAAAAElF" +
+ "TkSuQmCC";
- let transparentImageDataUri = "data:image/gif;base64,R0lGODlhAQABAIAAA"
- + "AAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
+ const TRANSPARENT_IMAGE_DATA_URI = "data:image/gif;base64,R0lGODlhAQABAIAAA" +
+ "AAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
self.indicateBlockedVisibleObjects = function(doc, blockedURIs) {
- if (Object.getOwnPropertyNames(blockedURIs).length == 0) {
+ if (Object.getOwnPropertyNames(blockedURIs).length === 0) {
// there are no blocked uris
return;
}
@@ -80,17 +80,17 @@ var ManagerForBlockedContent = (function() {
img.style.border = "solid 1px #fcc";
img.style.backgroundRepeat = "no-repeat";
img.style.backgroundPosition = "center center";
- img.style.backgroundImage = "url('" + missingImageDataUri + "')";
+ img.style.backgroundImage = "url('" + MISSING_IMAGE_DATA_URI + "')";
if (!img.width) {
img.width = 50;
}
if (!img.height) {
img.height = 50;
}
- img.title = "[" + blockedURIs[img.src].identifier + "]"
- + (img.title ? " " + img.title : "")
- + (img.alt ? " " + img.alt : "");
- img.src = transparentImageDataUri;
+ img.title = "[" + blockedURIs[img.src].identifier + "]" +
+ (img.title ? " " + img.title : "") +
+ (img.alt ? " " + img.alt : "");
+ img.src = TRANSPARENT_IMAGE_DATA_URI;
}
}
};
diff --git a/src/content/ui/frame.dom-content-loaded.js b/src/content/ui/frame.dom-content-loaded.js
index d24acbc..ffb81b5 100644
--- a/src/content/ui/frame.dom-content-loaded.js
+++ b/src/content/ui/frame.dom-content-loaded.js
@@ -75,7 +75,7 @@ var ManagerForDOMContentLoaded = (function() {
// <--- the above comment is very old – is it (still) true that
// onDOMContentLoaded is called multiple times?
var doc = event.originalTarget;
- if (doc.nodeName != "#document") {
+ if (doc.nodeName !== "#document") {
// only documents
return;
}
@@ -101,7 +101,8 @@ var ManagerForDOMContentLoaded = (function() {
// Indicating blocked visible objects isn't an urgent task, so this should
// be done async.
Utils.runAsync(function() {
- ManagerForBlockedContent.indicateBlockedVisibleObjects(doc, blockedURIs);
+ ManagerForBlockedContent.indicateBlockedVisibleObjects(doc,
+ blockedURIs);
});
}
@@ -166,7 +167,7 @@ var ManagerForDOMContentLoaded = (function() {
var metaTags = doc.getElementsByTagName("meta");
for (var i = 0; i < metaTags.length; i++) {
let metaTag = metaTags[i];
- if (!metaTag.httpEquiv || metaTag.httpEquiv.toLowerCase() != "refresh") {
+ if (!metaTag.httpEquiv || metaTag.httpEquiv.toLowerCase() !== "refresh") {
continue;
}
diff --git a/src/content/ui/frame.js b/src/content/ui/frame.js
index 2eeaadf..e54cb53 100644
--- a/src/content/ui/frame.js
+++ b/src/content/ui/frame.js
@@ -106,7 +106,7 @@
// Link clicked.
// I believe an empty href always gets filled in with the current URL so
// it will never actually be empty. However, I don't know this for certain.
- if (event.target.nodeName.toLowerCase() == "a" && event.target.href) {
+ if (event.target.nodeName.toLowerCase() === "a" && event.target.href) {
overlayComm.run(function() {
sendSyncMessage(C.MM_PREFIX + "notifyLinkClicked",
{origin: event.target.ownerDocument.URL,
@@ -117,8 +117,8 @@
// Form submit button clicked. This can either be directly (e.g. mouseclick,
// enter/space while the the submit button has focus) or indirectly (e.g.
// pressing enter when a text input has focus).
- if (event.target.nodeName.toLowerCase() == "input" &&
- event.target.type.toLowerCase() == "submit" &&
+ if (event.target.nodeName.toLowerCase() === "input" &&
+ event.target.type.toLowerCase() === "submit" &&
event.target.form && event.target.form.action) {
overlayComm.run(function() {
sendSyncMessage(C.MM_PREFIX + "registerFormSubmitted",
@@ -127,7 +127,7 @@
});
return;
}
- };
+ }
framescriptEnv.addStartupFunction(Environment.LEVELS.INTERFACE, function() {
framescriptEnv.elManager.addListener(mm, "click", mouseClicked, true);
diff --git a/src/content/ui/menu.js b/src/content/ui/menu.js
index d46e9a5..6d006eb 100644
--- a/src/content/ui/menu.js
+++ b/src/content/ui/menu.js
@@ -98,9 +98,6 @@ window.rpcontinued.menu = (function () {
lists.addRules = $id("rpc-rules-add");
lists.removeRules = $id("rpc-rules-remove");
- var conflictCount = RequestProcessor.getConflictingExtensions().length;
- var hideConflictInfo = (conflictCount == 0);
-
rpcontinued.overlay.OverlayEnvironment.addShutdownFunction(
Environment.LEVELS.INTERFACE,
@@ -170,8 +167,8 @@ window.rpcontinued.menu = (function () {
// "self._currentUri: " + self._currentUri);
self._currentUriObj = DomainUtil.getUriObject(self._currentUri);
- self._isChromeUri = self._currentUriObj.scheme == "chrome";
- //self._currentUriIsHttps = self._currentUriObj.scheme == "https";
+ self._isChromeUri = self._currentUriObj.scheme === "chrome";
+ //self._currentUriIsHttps = self._currentUriObj.scheme === "https";
Logger.info(Logger.TYPE_INTERNAL,
"self._currentUri: " + self._currentUri);
@@ -250,9 +247,9 @@ window.rpcontinued.menu = (function () {
var sorting = rpPrefBranch.getCharPref('menu.sorting');
var showNumRequests = rpPrefBranch.getBoolPref('menu.info.showNumRequests');
- if (sorting == "numRequests") {
+ if (sorting === "numRequests") {
values.sort(GUILocation.sortByNumRequestsCompareFunction);
- } else if (sorting == "destName") {
+ } else if (sorting === "destName") {
values.sort(GUILocation.compareFunction);
}
@@ -260,7 +257,7 @@ window.rpcontinued.menu = (function () {
var guiLocation = values[i];
var props = guiLocation.properties;
- var num = undefined;
+ let num;
if (true === showNumRequests) {
num = props.numRequests;
if (props.numAllowedRequests > 0 && props.numBlockedRequests > 0) {
@@ -271,9 +268,9 @@ window.rpcontinued.menu = (function () {
var newitem = self._addListItem(list, 'rpc-od-item', guiLocation, num);
newitem.setAttribute("default-policy",
- (props.numDefaultPolicyRequests > 0 ? "true" : "false"));
+ props.numDefaultPolicyRequests > 0 ? "true" : "false");
newitem.setAttribute("requests-blocked",
- (props.numBlockedRequests > 0 ? "true" : "false"));
+ props.numBlockedRequests > 0 ? "true" : "false");
}
} else {
values.sort();
@@ -303,9 +300,9 @@ window.rpcontinued.menu = (function () {
self._originNumRequestsItem.setAttribute("value", numRequests);
self._originItem.setAttribute("default-policy",
- (props.numDefaultPolicyRequests > 0 ? "true" : "false"));
+ props.numDefaultPolicyRequests > 0 ? "true" : "false");
self._originItem.setAttribute("requests-blocked",
- (props.numBlockedRequests > 0 ? "true" : "false"));
+ props.numBlockedRequests > 0 ? "true" : "false");
};
self._populateOtherOrigins = function() {
@@ -355,7 +352,7 @@ window.rpcontinued.menu = (function () {
// This should never happen, the destsMixed destination should have
// been added in the destsWithBlockedRequests-loop.
Logger.warning(Logger.TYPE_INTERNAL, "mixed dest was" +
- " not added to `destsMixed` list: <" + dest.dest + ">");
+ " not added to `destsMixed` list: <" + allowedGUIDest + ">");
destsMixed.push(allowedGUIDest);
}
}
@@ -404,14 +401,14 @@ window.rpcontinued.menu = (function () {
//var item = self._addMenuItemTempDenyOrigin(lists.addRules, ruleData);
} else {
if (mayPermRulesBeAdded === true) {
- var item = self._addMenuItemAllowOrigin(lists.addRules, ruleData);
+ self._addMenuItemAllowOrigin(lists.addRules, ruleData);
}
- var item = self._addMenuItemTempAllowOrigin(lists.addRules, ruleData);
+ self._addMenuItemTempAllowOrigin(lists.addRules, ruleData);
}
}
if (dest) {
- ruleData['d'] = {
+ ruleData.d = {
'h' : self._addWildcard(dest)
};
var destOnlyRuleData = {
@@ -421,55 +418,48 @@ window.rpcontinued.menu = (function () {
};
//if (Prefs.isDefaultAllow()) {
if (self._isCurrentlySelectedDestAllowed ||
- (!PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData) &&
- !PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData))) {
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData)) {
// show "Block requests" if the destination was allowed
// OR if there's no blocking rule (i.e. the request was blocked "by default")
// -- this enables support for blacklisting.
if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
!PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData)) {
if (mayPermRulesBeAdded === true) {
- var item = self._addMenuItemDenyOriginToDest(
- lists.addRules, ruleData);
+ self._addMenuItemDenyOriginToDest(lists.addRules, ruleData);
}
- var item = self._addMenuItemTempDenyOriginToDest(
- lists.addRules, ruleData);
+ self._addMenuItemTempDenyOriginToDest(lists.addRules, ruleData);
}
if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData) &&
!PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData)) {
if (mayPermRulesBeAdded === true) {
- var item = self._addMenuItemDenyDest(
- lists.addRules, destOnlyRuleData);
+ self._addMenuItemDenyDest(lists.addRules, destOnlyRuleData);
}
- var item = self._addMenuItemTempDenyDest(
- lists.addRules, destOnlyRuleData);
+ self._addMenuItemTempDenyDest(lists.addRules, destOnlyRuleData);
}
}
if (self._isCurrentlySelectedDestBlocked ||
- (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
- !PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData))) {
+ !PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_ALLOW,
+ destOnlyRuleData)) {
// show "Allow requests" if the destination was blocked
// OR if there's no allow-rule (i.e. the request was allowed "by default")
// -- this enables support for whitelisting.
if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
!PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData)) {
if (mayPermRulesBeAdded === true) {
- var item = self._addMenuItemAllowOriginToDest(
- lists.addRules, ruleData);
+ self._addMenuItemAllowOriginToDest(lists.addRules, ruleData);
}
- var item = self._addMenuItemTempAllowOriginToDest(
- lists.addRules, ruleData);
+ self._addMenuItemTempAllowOriginToDest(lists.addRules, ruleData);
}
if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData) &&
!PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData)) {
if (mayPermRulesBeAdded === true) {
- var item = self._addMenuItemAllowDest(
- lists.addRules, destOnlyRuleData);
+ self._addMenuItemAllowDest(lists.addRules, destOnlyRuleData);
}
- var item = self._addMenuItemTempAllowDest(
- lists.addRules, destOnlyRuleData);
+ self._addMenuItemTempAllowDest(lists.addRules, destOnlyRuleData);
}
}
}
@@ -542,10 +532,10 @@ window.rpcontinued.menu = (function () {
};
self._activateOriginItem = function(item) {
- if (item.id == 'rpc-origin') {
+ if (item.id === 'rpc-origin') {
// it's _the_ origin
self._currentlySelectedOrigin = self._originDomainnameItem.value;
- } else if (item.parentNode.id == 'rpc-other-origins-list') {
+ } else if (item.parentNode.id === 'rpc-other-origins-list') {
// it's an otherOrigin
self._currentlySelectedOrigin = item.getElementsByClassName("domainname")[0].value;
}
@@ -562,10 +552,10 @@ window.rpcontinued.menu = (function () {
self._activateDestinationItem = function(item) {
self._currentlySelectedDest = item.getElementsByClassName("domainname")[0].value;
- if (item.parentNode.id == 'rpc-blocked-destinations-list') {
+ if (item.parentNode.id === 'rpc-blocked-destinations-list') {
self._isCurrentlySelectedDestBlocked = true;
self._isCurrentlySelectedDestAllowed = false;
- } else if (item.parentNode.id == 'rpc-allowed-destinations-list') {
+ } else if (item.parentNode.id === 'rpc-allowed-destinations-list') {
self._isCurrentlySelectedDestBlocked = false;
self._isCurrentlySelectedDestAllowed = true;
} else {
@@ -584,19 +574,19 @@ window.rpcontinued.menu = (function () {
// TODO: rather than compare IDs, this should probably compare against
// the elements we already have stored in variables. That is, assuming
// equality comparisons work that way here.
- if (item.nodeName == "label" && item.parentNode.nodeName == "hbox") {
+ if (item.nodeName === "label" && item.parentNode.nodeName === "hbox") {
// item should be the <hbox>
item = item.parentNode;
}
- if (item.id == 'rpc-origin' ||
- item.parentNode.id == 'rpc-other-origins-list') {
+ if (item.id === 'rpc-origin' ||
+ item.parentNode.id === 'rpc-other-origins-list') {
self._activateOriginItem(item);
- } else if (item.parentNode.id == 'rpc-blocked-destinations-list' ||
- item.parentNode.id == 'rpc-mixed-destinations-list' ||
- item.parentNode.id == 'rpc-allowed-destinations-list') {
+ } else if (item.parentNode.id === 'rpc-blocked-destinations-list' ||
+ item.parentNode.id === 'rpc-mixed-destinations-list' ||
+ item.parentNode.id === 'rpc-allowed-destinations-list') {
self._activateDestinationItem(item);
- } else if (item.parentNode.id == 'rpc-rules-remove' ||
- item.parentNode.id == 'rpc-rules-add') {
+ } else if (item.parentNode.id === 'rpc-rules-remove' ||
+ item.parentNode.id === 'rpc-rules-add') {
self._processRuleSelection(item);
} else {
Logger.severe(Logger.TYPE_ERROR,
@@ -608,12 +598,13 @@ window.rpcontinued.menu = (function () {
var ruleData = item.requestpolicyRuleData;
var ruleAction = item.requestpolicyRuleAction;
- if (item.getAttribute('selected-rule') == 'true') {
+ var undo;
+ if (item.getAttribute('selected-rule') === 'true') {
item.setAttribute('selected-rule', 'false');
- var undo = true;
+ undo = true;
} else {
item.setAttribute('selected-rule', 'true');
- var undo = false;
+ undo = false;
}
if (!ruleData) {
@@ -636,11 +627,11 @@ window.rpcontinued.menu = (function () {
// only cares whether it's an allow/deny and temporary and drops the ruleData
// argument straight into the ruleset?
var origin, dest;
- if (ruleData['o'] && ruleData['o']['h']) {
- origin = ruleData['o']['h'];
+ if (ruleData.o && ruleData.o.h) {
+ origin = ruleData.o.h;
}
- if (ruleData['d'] && ruleData['d']['h']) {
- dest = ruleData['d']['h'];
+ if (ruleData.d && ruleData.d.h) {
+ dest = ruleData.d.h;
}
if (!self._ruleChangeQueues[ruleAction]) {
@@ -660,7 +651,7 @@ window.rpcontinued.menu = (function () {
for (var canonicalRule in self._ruleChangeQueues[ruleAction]) {
var ruleData = self._ruleChangeQueues[ruleAction][canonicalRule];
self._processRuleChange(ruleAction, ruleData);
- var rulesChanged = true;
+ rulesChanged = true;
}
}
@@ -691,7 +682,6 @@ window.rpcontinued.menu = (function () {
break;
default:
throw 'action not implemented: ' + ruleAction;
- break;
}
};
@@ -750,9 +740,6 @@ window.rpcontinued.menu = (function () {
self._getOriginGUILocationProperties = function() {
var allRequests = self._allRequestsOnDocument.getAll();
- var allowSameDomain = Prefs.isDefaultAllow() ||
- Prefs.isDefaultAllowSameDomain();
-
var properties = new GUILocationProperties();
for (var originUri in allRequests) {
@@ -785,7 +772,7 @@ window.rpcontinued.menu = (function () {
// near here in the first place.
// Is this an issue anymore? This may have been slipping through due to
// a bug that has since been fixed. Disabling for now.
- //if (originBase == 'browser') {
+ //if (originBase === 'browser') {
// continue;
//}
@@ -840,20 +827,20 @@ window.rpcontinued.menu = (function () {
// Stop allowing
self._addMenuItemStopAllowingOrigin = function(list, ruleData, subscriptionOverride) {
- var originHost = ruleData["o"]["h"];
+ var originHost = ruleData.o.h;
var ruleAction = subscriptionOverride ? 'deny' : 'stop-allow';
return self._addMenuItemHelper(list, ruleData, 'stopAllowingOrigin', [originHost], ruleAction, 'rpc-stop-rule rpc-stop-allow');
};
self._addMenuItemStopAllowingDest = function(list, ruleData, subscriptionOverride) {
- var destHost = ruleData["d"]["h"];
+ var destHost = ruleData.d.h;
var ruleAction = subscriptionOverride ? 'deny' : 'stop-allow';
return self._addMenuItemHelper(list, ruleData, 'stopAllowingDestination', [destHost], ruleAction, 'rpc-stop-rule rpc-stop-allow');
};
self._addMenuItemStopAllowingOriginToDest = function(list, ruleData, subscriptionOverride) {
- var originHost = ruleData["o"]["h"];
- var destHost = ruleData["d"]["h"];
+ var originHost = ruleData.o.h;
+ var destHost = ruleData.d.h;
var ruleAction = subscriptionOverride ? 'deny' : 'stop-allow';
return self._addMenuItemHelper(list, ruleData, 'stopAllowingOriginToDestination', [originHost, destHost], ruleAction, 'rpc-stop-rule rpc-stop-allow');
};
@@ -861,56 +848,56 @@ window.rpcontinued.menu = (function () {
// Allow
self._addMenuItemAllowOrigin = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
+ var originHost = ruleData.o.h;
return self._addMenuItemHelper(list, ruleData, 'allowOrigin', [originHost], 'allow', 'rpc-start-rule rpc-allow');
};
self._addMenuItemAllowDest = function(list, ruleData) {
- var destHost = ruleData["d"]["h"];
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData, 'allowDestination', [destHost], 'allow', 'rpc-start-rule rpc-allow');
};
self._addMenuItemAllowOriginToDest = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
- var destHost = ruleData["d"]["h"];
+ var originHost = ruleData.o.h;
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData, 'allowOriginToDestination', [originHost, destHost], 'allow', 'rpc-start-rule rpc-allow');
};
// Allow temp
self._addMenuItemTempAllowOrigin = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
+ var originHost = ruleData.o.h;
return self._addMenuItemHelper(list, ruleData, 'allowOriginTemporarily', [originHost], 'allow-temp', 'rpc-start-rule rpc-allow rpc-temporary');
};
self._addMenuItemTempAllowDest = function(list, ruleData) {
- var destHost = ruleData["d"]["h"];
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData, 'allowDestinationTemporarily', [destHost], 'allow-temp', 'rpc-start-rule rpc-allow rpc-temporary');
};
self._addMenuItemTempAllowOriginToDest = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
- var destHost = ruleData["d"]["h"];
+ var originHost = ruleData.o.h;
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData, 'allowOriginToDestinationTemporarily', [originHost, destHost], 'allow-temp', 'rpc-start-rule rpc-allow rpc-temporary');
};
// Stop denying
self._addMenuItemStopDenyingOrigin = function(list, ruleData, subscriptionOverride) {
- var originHost = ruleData["o"]["h"];
+ var originHost = ruleData.o.h;
var ruleAction = subscriptionOverride ? 'allow' : 'stop-deny';
return self._addMenuItemHelper(list, ruleData, 'stopDenyingOrigin', [originHost], ruleAction, 'rpc-stop-rule rpc-stop-deny');
};
self._addMenuItemStopDenyingDest = function(list, ruleData, subscriptionOverride) {
- var destHost = ruleData["d"]["h"];
+ var destHost = ruleData.d.h;
var ruleAction = subscriptionOverride ? 'allow' : 'stop-deny';
return self._addMenuItemHelper(list, ruleData, 'stopDenyingDestination', [destHost], ruleAction, 'rpc-stop-rule rpc-stop-deny');
};
self._addMenuItemStopDenyingOriginToDest = function(list, ruleData, subscriptionOverride) {
- var originHost = ruleData["o"]["h"];
- var destHost = ruleData["d"]["h"];
+ var originHost = ruleData.o.h;
+ var destHost = ruleData.d.h;
var ruleAction = subscriptionOverride ? 'allow' : 'stop-deny';
return self._addMenuItemHelper(list, ruleData, 'stopDenyingOriginToDestination', [originHost, destHost], ruleAction, 'rpc-stop-rule rpc-stop-deny');
};
@@ -918,36 +905,36 @@ window.rpcontinued.menu = (function () {
// Deny
self._addMenuItemDenyOrigin = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
+ var originHost = ruleData.o.h;
return self._addMenuItemHelper(list, ruleData, 'denyOrigin', [originHost], 'deny', 'rpc-start-rule rpc-deny');
};
self._addMenuItemDenyDest = function(list, ruleData) {
- var destHost = ruleData["d"]["h"];
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData, 'denyDestination', [destHost], 'deny', 'rpc-start-rule rpc-deny');
};
self._addMenuItemDenyOriginToDest = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
- var destHost = ruleData["d"]["h"];
+ var originHost = ruleData.o.h;
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData, 'denyOriginToDestination', [originHost, destHost], 'deny', 'rpc-start-rule rpc-deny');
};
// Deny temp
self._addMenuItemTempDenyOrigin = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
+ var originHost = ruleData.o.h;
return self._addMenuItemHelper(list, ruleData, 'denyOriginTemporarily', [originHost], 'deny-temp', 'rpc-start-rule rpc-deny rpc-temporary');
};
self._addMenuItemTempDenyDest = function(list, ruleData) {
- var destHost = ruleData["d"]["h"];
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData, 'denyDestinationTemporarily', [destHost], 'deny-temp', 'rpc-start-rule rpc-deny rpc-temporary');
};
self._addMenuItemTempDenyOriginToDest = function(list, ruleData) {
- var originHost = ruleData["o"]["h"];
- var destHost = ruleData["d"]["h"];
+ var originHost = ruleData.o.h;
+ var destHost = ruleData.d.h;
return self._addMenuItemHelper(list, ruleData,
'denyOriginToDestinationTemporarily', [originHost, destHost],
'deny-temp', 'rpc-start-rule rpc-deny rpc-temporary');
@@ -972,12 +959,12 @@ window.rpcontinued.menu = (function () {
self._ruleDataPartToDisplayString = function(ruleDataPart) {
var str = "";
- if (ruleDataPart["s"]) {
- str += ruleDataPart["s"] + "://";
+ if (ruleDataPart.s) {
+ str += ruleDataPart.s + "://";
}
- str += ruleDataPart["h"] || "*";
- if (ruleDataPart["port"]) {
- str += ":" + ruleDataPart["port"];
+ str += ruleDataPart.h || "*";
+ if (ruleDataPart.port) {
+ str += ":" + ruleDataPart.port;
}
// TODO: path
return str;
@@ -985,38 +972,42 @@ window.rpcontinued.menu = (function () {
self._ruleDataToFormatVariables = function(rawRule) {
var fmtVars = [];
- if (rawRule["o"]) {
- fmtVars.push(self._ruleDataPartToDisplayString(rawRule["o"]));
+ if (rawRule.o) {
+ fmtVars.push(self._ruleDataPartToDisplayString(rawRule.o));
}
- if (rawRule["d"]) {
- fmtVars.push(self._ruleDataPartToDisplayString(rawRule["d"]));
+ if (rawRule.d) {
+ fmtVars.push(self._ruleDataPartToDisplayString(rawRule.d));
}
return fmtVars;
};
- self._addMenuItemRemoveAllowRule = function(list, rawRule, subscriptionOverride) {
- var fmtVars = self._ruleDataToFormatVariables(rawRule);
-
- if (rawRule["o"] && rawRule["d"]) {
- return self._addMenuItemStopAllowingOriginToDest(list, rawRule, subscriptionOverride);
- } else if (rawRule["o"]) {
- return self._addMenuItemStopAllowingOrigin(list, rawRule, subscriptionOverride);
- } else if (rawRule["d"]) {
- return self._addMenuItemStopAllowingDest(list, rawRule, subscriptionOverride);
+ self._addMenuItemRemoveAllowRule = function(list, rawRule,
+ subscriptionOverride) {
+ if (rawRule.o && rawRule.d) {
+ return self._addMenuItemStopAllowingOriginToDest(list, rawRule,
+ subscriptionOverride);
+ } else if (rawRule.o) {
+ return self._addMenuItemStopAllowingOrigin(list, rawRule,
+ subscriptionOverride);
+ } else if (rawRule.d) {
+ return self._addMenuItemStopAllowingDest(list, rawRule,
+ subscriptionOverride);
} else {
throw "Invalid rule data: no origin or destination parts.";
}
};
- self._addMenuItemRemoveDenyRule = function(list, rawRule, subscriptionOverride) {
- var fmtVars = self._ruleDataToFormatVariables(rawRule);
-
- if (rawRule["o"] && rawRule["d"]) {
- return self._addMenuItemStopDenyingOriginToDest(list, rawRule, subscriptionOverride);
- } else if (rawRule["o"]) {
- return self._addMenuItemStopDenyingOrigin(list, rawRule, subscriptionOverride);
- } else if (rawRule["d"]) {
- return self._addMenuItemStopDenyingDest(list, rawRule, subscriptionOverride);
+ self._addMenuItemRemoveDenyRule = function(list, rawRule,
+ subscriptionOverride) {
+ if (rawRule.o && rawRule.d) {
+ return self._addMenuItemStopDenyingOriginToDest(list, rawRule,
+ subscriptionOverride);
+ } else if (rawRule.o) {
+ return self._addMenuItemStopDenyingOrigin(list, rawRule,
+ subscriptionOverride);
+ } else if (rawRule.d) {
+ return self._addMenuItemStopDenyingDest(list, rawRule,
+ subscriptionOverride);
} else {
throw "Invalid rule data: no origin or destination parts.";
}
@@ -1075,7 +1066,7 @@ window.rpcontinued.menu = (function () {
var rawRule = Ruleset.matchToRawRule(match);
if (!self._currentlySelectedDest) {
- if (rawRule['d'] && rawRule['d']['h']) {
+ if (rawRule.d && rawRule.d.h) {
continue;
}
}
@@ -1157,7 +1148,7 @@ window.rpcontinued.menu = (function () {
var rawRule = Ruleset.matchToRawRule(match);
if (!self._currentlySelectedDest) {
- if (rawRule['d'] && rawRule['d']['h']) {
+ if (rawRule.d && rawRule.d.h) {
continue;
}
}
@@ -1227,9 +1218,9 @@ window.rpcontinued.menu = (function () {
if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
!PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData)) {
if (mayPermRulesBeAdded === true) {
- var item = self._addMenuItemAllowOriginToDest(list, ruleData);
+ self._addMenuItemAllowOriginToDest(list, ruleData);
}
- var item = self._addMenuItemTempAllowOriginToDest(list, ruleData);
+ self._addMenuItemTempAllowOriginToDest(list, ruleData);
}
var destOnlyRuleData = {
@@ -1240,9 +1231,9 @@ window.rpcontinued.menu = (function () {
if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData) &&
!PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData)) {
if (mayPermRulesBeAdded === true) {
- var item = self._addMenuItemAllowDest(list, destOnlyRuleData);
+ self._addMenuItemAllowDest(list, destOnlyRuleData);
}
- var item = self._addMenuItemTempAllowDest(list, destOnlyRuleData);
+ self._addMenuItemTempAllowDest(list, destOnlyRuleData);
}
}
};
diff --git a/src/content/ui/overlay.js b/src/content/ui/overlay.js
index 9da2926..83eb858 100644
--- a/src/content/ui/overlay.js
+++ b/src/content/ui/overlay.js
@@ -79,7 +79,6 @@ window.rpcontinued.overlay = (function () {
let blockedContentStateUpdateDelay = 250; // milliseconds
let blockedContentCheckTimeoutId = null;
- let blockedContentCheckMinWaitOnObservedBlockedRequest = 500;
let blockedContentCheckLastTime = 0;
let popupElement = null;
@@ -127,7 +126,7 @@ window.rpcontinued.overlay = (function () {
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo);
- isFennec = (appInfo.ID === "{a23983c0-fd0e-11dc-95ff-0800200c9a66}");
+ isFennec = appInfo.ID === "{a23983c0-fd0e-11dc-95ff-0800200c9a66}";
if (isFennec) {
Logger.dump("Detected Fennec.");
@@ -565,11 +564,11 @@ window.rpcontinued.overlay = (function () {
// https://en.wikipedia.org/wiki/URL_redirection
];
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
-
+
let notificationElem = notificationBox.appendNotification(
notificationLabel, notificationValue,
"chrome://browser/skin/Info.png", priority, buttons);
-
+
// Let the notification persist at least 300ms. This is needed in the
// following scenario:
// If an URL is entered on an empty tab (e.g. "about:blank"),
diff --git a/src/content/ui/request-log.filtering.js b/src/content/ui/request-log.filtering.js
index bbfbb61..a519694 100644
--- a/src/content/ui/request-log.filtering.js
+++ b/src/content/ui/request-log.filtering.js
@@ -56,7 +56,7 @@ window.rpcontinued.requestLog = (function (self) {
elements.filterTextbox.value = "";
elements.filterTextbox.focus();
self.filterChanged();
- }
+ };
diff --git a/src/content/ui/request-log.interface.js b/src/content/ui/request-log.interface.js
index c05e050..c8faeaa 100644
--- a/src/content/ui/request-log.interface.js
+++ b/src/content/ui/request-log.interface.js
@@ -75,7 +75,8 @@ window.rpcontinued.requestLog = (function (self) {
var forbidden = true;
try {
var uri = DomainUtil.getUriObject(content);
- if (uri.scheme == 'http' || uri.scheme == 'https' || uri.scheme == 'ftp') {
+ if (uri.scheme === 'http' || uri.scheme === 'https' ||
+ uri.scheme === 'ftp') {
forbidden = false;
}
} catch (e) {
diff --git a/src/content/ui/request-log.js b/src/content/ui/request-log.js
index 45898e0..e444f7f 100644
--- a/src/content/ui/request-log.js
+++ b/src/content/ui/request-log.js
@@ -53,7 +53,7 @@ window.rpcontinued.requestLog = (function (self) {
function init() {
- self.tree = $id("rpcontinued-requestLog-tree")
+ self.tree = $id("rpcontinued-requestLog-tree");
self.tree.view = self.treeView;
diff --git a/src/content/ui/request-log.tree-view.js b/src/content/ui/request-log.tree-view.js
index c25e770..0748b1d 100644
--- a/src/content/ui/request-log.tree-view.js
+++ b/src/content/ui/request-log.tree-view.js
@@ -41,7 +41,7 @@ window.rpcontinued.requestLog = (function (self) {
function getVisibleRowAtIndex(index) {
return self.visibleRows[self.visibleRows.length - index - 1];
- };
+ }
@@ -136,7 +136,7 @@ window.rpcontinued.requestLog = (function (self) {
performActionOnCell: function(action, aIndex, aColumn) {},
getRowProperties: function(aIndex) {
- return (getVisibleRowAtIndex(aIndex)[2]) ? "blocked" : "allowed";
+ return getVisibleRowAtIndex(aIndex)[2] ? "blocked" : "allowed";
},
getCellProperties: function(aIndex, aColumn) {
diff --git a/src/content/ui/xul-trees.js b/src/content/ui/xul-trees.js
index fa6c7f3..6c8d010 100644
--- a/src/content/ui/xul-trees.js
+++ b/src/content/ui/xul-trees.js
@@ -51,7 +51,7 @@ exports.toolbarbutton = [
exports.mainTree = [
{
- parent: {id: (isSeamonkey ? "taskPopup" : "menu_ToolsPopup")},
+ parent: {id: isSeamonkey ? "taskPopup" : "menu_ToolsPopup"},
tag: "menu",
attributes: {label: "RequestPolicy Continued",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list