[Pkg-mozext-commits] [requestpolicy] 167/257: [ref] don't use == and != anymore
David Prévot
taffit at moszumanska.debian.org
Thu Jan 28 03:20:09 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 d89c2e4dd45b598d11a958b1760508fb923b3c41
Author: Martin Kimmerle <dev at 256k.de>
Date: Tue Dec 1 14:28:46 2015 +0100
[ref] don't use == and != anymore
---
src/content/lib/gui-location.jsm | 4 +-
src/content/lib/logger.jsm | 2 +-
src/content/lib/policy-manager.jsm | 3 +-
src/content/lib/prefs.jsm | 4 +-
src/content/lib/request-processor.compat.js | 2 +-
src/content/lib/request-processor.jsm | 75 +++++++++++++-------------
src/content/lib/request-processor.redirects.js | 3 +-
src/content/lib/request-result.jsm | 6 +--
src/content/lib/request-set.jsm | 2 +-
src/content/lib/request.jsm | 10 ++--
src/content/lib/ruleset.jsm | 71 ++++++++++++------------
src/content/lib/subscription.jsm | 10 ++--
src/content/lib/utils/domains.jsm | 24 ++++-----
src/content/lib/utils/files.jsm | 2 +-
src/content/lib/utils/info.jsm | 4 +-
src/content/main/pref-manager.jsm | 2 +-
src/content/main/requestpolicy-service.jsm | 2 +-
src/content/main/window-manager.listener.js | 8 +--
src/content/ui/frame.js | 2 +-
src/content/ui/menu.js | 28 +++++-----
src/content/ui/request-log.interface.js | 2 +-
src/content/ui/request-log.tree-view.js | 6 +--
22 files changed, 139 insertions(+), 133 deletions(-)
diff --git a/src/content/lib/gui-location.jsm b/src/content/lib/gui-location.jsm
index fa439a6..af71abf 100644
--- a/src/content/lib/gui-location.jsm
+++ b/src/content/lib/gui-location.jsm
@@ -62,7 +62,7 @@ GUILocation.merge = function (guiLocation, location1, location2) {
* @static
*/
GUILocation.existsInArray = function (locationString, locations) {
- return (GUILocation.indexOfLocationInArray(locationString, locations) != -1);
+ return GUILocation.indexOfLocationInArray(locationString, locations) !== -1;
};
/**
@@ -79,7 +79,7 @@ GUILocation.indexOfLocationInArray = function (locationString, locations) {
locationString = locationString.value;
}
for (var i in locations) {
- if (locations[i].value == locationString) {
+ if (locations[i].value === locationString) {
return i;
}
}
diff --git a/src/content/lib/logger.jsm b/src/content/lib/logger.jsm
index 0c75a18..b50754e 100644
--- a/src/content/lib/logger.jsm
+++ b/src/content/lib/logger.jsm
@@ -182,7 +182,7 @@ var Logger = (function() {
self.dump = doLog.bind(self, self.LEVEL_DEBUG, self.TYPE_INTERNAL);
self.vardump = function(obj, name, ignoreFunctions) {
- if (name != undefined) {
+ if (name !== undefined) {
self.dump(name + " : " + obj);
} else {
self.dump(obj);
diff --git a/src/content/lib/policy-manager.jsm b/src/content/lib/policy-manager.jsm
index 30bc60d..46d3b75 100644
--- a/src/content/lib/policy-manager.jsm
+++ b/src/content/lib/policy-manager.jsm
@@ -176,7 +176,8 @@ var PolicyManager = (function () {
};
function assertRuleAction(ruleAction) {
- if (ruleAction != C.RULE_ACTION_ALLOW && ruleAction != C.RULE_ACTION_DENY) {
+ if (ruleAction !== C.RULE_ACTION_ALLOW &&
+ ruleAction !== C.RULE_ACTION_DENY) {
throw "Invalid rule type: " + ruleAction;
}
}
diff --git a/src/content/lib/prefs.jsm b/src/content/lib/prefs.jsm
index 211bf8d..383089f 100644
--- a/src/content/lib/prefs.jsm
+++ b/src/content/lib/prefs.jsm
@@ -111,7 +111,7 @@ var Prefs = (function() {
function isPrefEmpty(pref) {
try {
let value = rpPrefBranch.getComplexValue(pref, Ci.nsISupportsString).data;
- return value == '';
+ return value === "";
} catch (e) {
return true;
}
@@ -137,7 +137,7 @@ var Prefs = (function() {
function observePref(subject, topic, data) {
- if (topic == "nsPref:changed") {
+ if (topic === "nsPref:changed") {
// Send an observer notification that a pref that affects RP has been
// changed.
// TODO: also send the pref's name and its branch
diff --git a/src/content/lib/request-processor.compat.js b/src/content/lib/request-processor.compat.js
index cb1d0f8..5f72390 100644
--- a/src/content/lib/request-processor.compat.js
+++ b/src/content/lib/request-processor.compat.js
@@ -68,7 +68,7 @@ RequestProcessor = (function(self) {
function initializeExtensionCompatibility() {
- if (compatibilityRules.length != 0) {
+ if (compatibilityRules.length !== 0) {
return;
}
diff --git a/src/content/lib/request-processor.jsm b/src/content/lib/request-processor.jsm
index 15d18f9..76eaa69 100644
--- a/src/content/lib/request-processor.jsm
+++ b/src/content/lib/request-processor.jsm
@@ -286,8 +286,8 @@ var RequestProcessor = (function () {
* @return {boolean} True if the request is a duplicate of the previous one.
*/
function isDuplicateRequest(request) {
- if (lastShouldLoadCheck.origin == request.originURI &&
- lastShouldLoadCheck.destination == request.destURI) {
+ if (lastShouldLoadCheck.origin === request.originURI &&
+ lastShouldLoadCheck.destination === request.destURI) {
var date = new Date();
if (date.getTime() - lastShouldLoadCheck.time <
lastShouldLoadCheckTimeout) {
@@ -487,7 +487,7 @@ var RequestProcessor = (function () {
var originURI = request.originURI;
var destURI = request.destURI;
- if (request.aRequestOrigin.scheme == "moz-nullprincipal") {
+ if (request.aRequestOrigin.scheme === "moz-nullprincipal") {
// Before RP has been forked, there was a hack: in case of a request
// with the origin's scheme being 'moz-nullprincipal', RequestPolicy
// used the documentURI of the request's context as the "real" origin
@@ -532,9 +532,9 @@ var RequestProcessor = (function () {
request.setOriginURI(originURI);
}
- if (request.aContentLocation.scheme == "view-source") {
+ if (request.aContentLocation.scheme === "view-source") {
var newDestURI = destURI.split(":").slice(1).join(":");
- if (newDestURI.indexOf("data:text/html") == 0) {
+ 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" +
@@ -549,19 +549,19 @@ var RequestProcessor = (function () {
}
}
- if (originURI == "about:blank" && request.aContext) {
+ if (originURI === "about:blank" && request.aContext) {
let domNode;
try {
domNode = request.aContext.QueryInterface(Ci.nsIDOMNode);
- } catch (e if e.result == Cr.NS_ERROR_NO_INTERFACE) {}
- if (domNode && domNode.nodeType == Ci.nsIDOMNode.DOCUMENT_NODE) {
+ } catch (e if e.result === Cr.NS_ERROR_NO_INTERFACE) {}
+ if (domNode && domNode.nodeType === Ci.nsIDOMNode.DOCUMENT_NODE) {
let newOriginURI;
if (request.aContext.documentURI &&
- request.aContext.documentURI != "about:blank") {
+ request.aContext.documentURI !== "about:blank") {
newOriginURI = request.aContext.documentURI;
} else if (request.aContext.ownerDocument &&
request.aContext.ownerDocument.documentURI &&
- request.aContext.ownerDocument.documentURI != "about:blank") {
+ request.aContext.ownerDocument.documentURI !== "about:blank") {
newOriginURI = request.aContext.ownerDocument.documentURI;
}
if (newOriginURI) {
@@ -586,7 +586,7 @@ var RequestProcessor = (function () {
// all of that data was cleared due to the new request.
// Example to test with: Click on "expand all" at
// http://code.google.com/p/SOME_PROJECT/source/detail?r=SOME_REVISION
- if (originURI == destURI) {
+ if (originURI === destURI) {
Logger.warning(Logger.TYPE_CONTENT,
"Allowing (but not recording) request " +
"where origin is the same as the destination: " + originURI);
@@ -599,10 +599,10 @@ var RequestProcessor = (function () {
let domNode;
try {
domNode = request.aContext.QueryInterface(Ci.nsIDOMNode);
- } catch (e if e.result == Cr.NS_ERROR_NO_INTERFACE) {}
+ } catch (e if e.result === Cr.NS_ERROR_NO_INTERFACE) {}
- if (domNode && domNode.nodeName == "LINK" &&
- (domNode.rel == "icon" || domNode.rel == "shortcut icon")) {
+ if (domNode && domNode.nodeName === "LINK" &&
+ (domNode.rel === "icon" || domNode.rel === "shortcut icon")) {
internal.faviconRequests[destURI] = true;
}
}
@@ -670,8 +670,8 @@ var RequestProcessor = (function () {
return accept("User-allowed redirect", request, true);
}
- if (request.aRequestOrigin.scheme == "chrome") {
- if (request.aRequestOrigin.asciiHost == "browser") {
+ if (request.aRequestOrigin.scheme === "chrome") {
+ if (request.aRequestOrigin.asciiHost === "browser") {
// "browser" origin shows up for favicon.ico and an address entered
// in address bar.
request.requestResult = new RequestResult(true,
@@ -707,10 +707,10 @@ var RequestProcessor = (function () {
let domNode;
try {
domNode = request.aContext.QueryInterface(Ci.nsIDOMNode);
- } catch (e if e.result == Cr.NS_ERROR_NO_INTERFACE) {}
+ } catch (e if e.result === Cr.NS_ERROR_NO_INTERFACE) {}
- if (domNode && domNode.nodeName == "xul:browser" &&
- domNode.currentURI && domNode.currentURI.spec == "about:blank") {
+ if (domNode && domNode.nodeName === "xul:browser" &&
+ domNode.currentURI && domNode.currentURI.spec === "about:blank") {
request.requestResult = new RequestResult(true,
REQUEST_REASON_NEW_WINDOW);
return accept("New window (should probably only be an allowed " +
@@ -720,8 +720,8 @@ var RequestProcessor = (function () {
// XMLHttpRequests made within chrome's context have these origins.
// Greasemonkey uses such a method to provide their cross-site xhr.
- if (originURI == "resource://gre/res/hiddenWindow.html" ||
- originURI == "resource://gre-resources/hiddenWindow.html") {
+ if (originURI === "resource://gre/res/hiddenWindow.html" ||
+ originURI === "resource://gre-resources/hiddenWindow.html") {
}
// Now that we have blacklists, a user could prevent themselves from
@@ -839,7 +839,7 @@ var RequestProcessor = (function () {
// destination but was changed into the current one), accept this
// request if the original destination would have been accepted.
// Check aExtra against CP_MAPPEDDESTINATION to stop further recursion.
- if (request.aExtra != CP_MAPPEDDESTINATION &&
+ if (request.aExtra !== CP_MAPPEDDESTINATION &&
internal.mappedDestinations[destURI]) {
for (let mappedDest in internal.mappedDestinations[destURI]) {
var mappedDestUriObj = internal.mappedDestinations[destURI][mappedDest];
@@ -848,7 +848,7 @@ var RequestProcessor = (function () {
let mappedResult = PolicyImplementation.shouldLoad(
request.aContentType, mappedDestUriObj, request.aRequestOrigin,
request.aContext, request.aMimeTypeGuess, CP_MAPPEDDESTINATION);
- if (mappedResult == CP_OK) {
+ if (mappedResult === CP_OK) {
return CP_OK;
}
}
@@ -860,7 +860,8 @@ var RequestProcessor = (function () {
} else {
// We didn't match any of the conditions in which to allow the request,
// so reject it.
- return request.aExtra == CP_MAPPEDDESTINATION ? CP_REJECT :
+ return request.aExtra === CP_MAPPEDDESTINATION ?
+ CP_REJECT :
reject("Denied by default policy", request);
}
@@ -893,7 +894,7 @@ var RequestProcessor = (function () {
var httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
try {
// Determine if prefetch requests are slipping through.
- if (httpChannel.getRequestHeader("X-moz") == "prefetch") {
+ if (httpChannel.getRequestHeader("X-moz") === "prefetch") {
// Seems to be too late to block it at this point. Calling the
// cancel(status) method didn't stop it.
Logger.warning(Logger.TYPE_CONTENT,
@@ -933,19 +934,20 @@ var RequestProcessor = (function () {
// we'll need to be dropping the query string there.
destinationUrl = destinationUrl.split("?")[0];
- if (internal.submittedForms[originUrl] == undefined) {
+ if (internal.submittedForms[originUrl] === undefined) {
internal.submittedForms[originUrl] = {};
}
- if (internal.submittedForms[originUrl][destinationUrl] == undefined) {
+ if (internal.submittedForms[originUrl][destinationUrl] === undefined) {
// TODO: See timestamp note for registerLinkClicked.
internal.submittedForms[originUrl][destinationUrl] = true;
}
// Keep track of a destination-indexed map, as well.
- if (internal.submittedFormsReverse[destinationUrl] == undefined) {
+ if (internal.submittedFormsReverse[destinationUrl] === undefined) {
internal.submittedFormsReverse[destinationUrl] = {};
}
- if (internal.submittedFormsReverse[destinationUrl][originUrl] == undefined) {
+ if (internal.
+ submittedFormsReverse[destinationUrl][originUrl] === undefined) {
// TODO: See timestamp note for registerLinkClicked.
internal.submittedFormsReverse[destinationUrl][originUrl] = true;
}
@@ -960,10 +962,10 @@ var RequestProcessor = (function () {
Logger.info(Logger.TYPE_INTERNAL,
"Link clicked from <" + originUrl + "> to <" + destinationUrl + ">.");
- if (internal.clickedLinks[originUrl] == undefined) {
+ if (internal.clickedLinks[originUrl] === undefined) {
internal.clickedLinks[originUrl] = {};
}
- if (internal.clickedLinks[originUrl][destinationUrl] == undefined) {
+ if (internal.clickedLinks[originUrl][destinationUrl] === undefined) {
// TODO: Possibly set the value to a timestamp that can be used elsewhere
// to determine if this is a recent click. This is probably necessary as
// multiple calls to shouldLoad get made and we need a way to allow
@@ -977,10 +979,10 @@ var RequestProcessor = (function () {
}
// Keep track of a destination-indexed map, as well.
- if (internal.clickedLinksReverse[destinationUrl] == undefined) {
+ if (internal.clickedLinksReverse[destinationUrl] === undefined) {
internal.clickedLinksReverse[destinationUrl] = {};
}
- if (internal.clickedLinksReverse[destinationUrl][originUrl] == undefined) {
+ if (internal.clickedLinksReverse[destinationUrl][originUrl] === undefined) {
// TODO: Possibly set the value to a timestamp, as described above.
internal.clickedLinksReverse[destinationUrl][originUrl] = true;
}
@@ -994,10 +996,11 @@ var RequestProcessor = (function () {
Logger.info(Logger.TYPE_INTERNAL, "User-allowed redirect from <" +
originUrl + "> to <" + destinationUrl + ">.");
- if (internal.userAllowedRedirects[originUrl] == undefined) {
+ if (internal.userAllowedRedirects[originUrl] === undefined) {
internal.userAllowedRedirects[originUrl] = {};
}
- if (internal.userAllowedRedirects[originUrl][destinationUrl] == undefined) {
+ if (internal.
+ userAllowedRedirects[originUrl][destinationUrl] === undefined) {
internal.userAllowedRedirects[originUrl][destinationUrl] = true;
}
};
@@ -1025,7 +1028,7 @@ var RequestProcessor = (function () {
*/
self.removeRequestObserver = function(observer) {
for (let i = 0; i < internal.requestObservers.length; i++) {
- if (internal.requestObservers[i] == observer) {
+ if (internal.requestObservers[i] === observer) {
Logger.debug(Logger.TYPE_INTERNAL,
"Removing request observer: " + observer.toString());
delete internal.requestObservers[i];
diff --git a/src/content/lib/request-processor.redirects.js b/src/content/lib/request-processor.redirects.js
index 92562e9..c2c9b9f 100644
--- a/src/content/lib/request-processor.redirects.js
+++ b/src/content/lib/request-processor.redirects.js
@@ -414,7 +414,8 @@ RequestProcessor = (function(self) {
var originPath = httpResponse.originURI.path;
// We always have to check "/favicon.ico" because Firefox will use this
// as a default path and that request won't pass through shouldLoad().
- if (originPath == "/favicon.ico" || internal.faviconRequests[originString]) {
+ if (originPath === "/favicon.ico" ||
+ internal.faviconRequests[originString]) {
// 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;
diff --git a/src/content/lib/request-result.jsm b/src/content/lib/request-result.jsm
index dee579f..658f07c 100644
--- a/src/content/lib/request-result.jsm
+++ b/src/content/lib/request-result.jsm
@@ -105,9 +105,9 @@ RequestResult.prototype.denyRulesExist = function() {
RequestResult.prototype.isDefaultPolicyUsed = function() {
// returns whether the default policy has been or will be used for this request.
- return (this.resultReason == REQUEST_REASON_DEFAULT_POLICY ||
- this.resultReason == REQUEST_REASON_DEFAULT_POLICY_INCONSISTENT_RULES ||
- this.resultReason == REQUEST_REASON_DEFAULT_SAME_DOMAIN);
+ return this.resultReason === REQUEST_REASON_DEFAULT_POLICY ||
+ this.resultReason === REQUEST_REASON_DEFAULT_POLICY_INCONSISTENT_RULES ||
+ this.resultReason === REQUEST_REASON_DEFAULT_SAME_DOMAIN;
};
RequestResult.prototype.isOnBlacklist = function() {
diff --git a/src/content/lib/request-set.jsm b/src/content/lib/request-set.jsm
index 1fdea3a..54c09af 100644
--- a/src/content/lib/request-set.jsm
+++ b/src/content/lib/request-set.jsm
@@ -128,7 +128,7 @@ RequestSet.prototype = {
* @param {Array} rules The rules that were triggered by this request.
*/
addRequest : function(originUri, destUri, requestResult) {
- if (requestResult == undefined) {
+ if (requestResult === undefined) {
Logger.warning(Logger.TYPE_INTERNAL,
"addRequest() was called without a requestResult object!" +
" Creating a new one. -- " +
diff --git a/src/content/lib/request.jsm b/src/content/lib/request.jsm
index 1f5c8e3..0aeaed7 100644
--- a/src/content/lib/request.jsm
+++ b/src/content/lib/request.jsm
@@ -192,21 +192,21 @@ NormalRequest.prototype.isInternal = function() {
// "global" dest are [some sort of interal requests]
// "browser" dest are [???]
- if (destHost == "global" || destHost == "browser") {
+ if (destHost === "global" || destHost === "browser") {
return true;
}
// see issue #180
- if (this.aRequestOrigin.scheme == 'about' &&
- this.aRequestOrigin.spec.indexOf("about:neterror?") == 0) {
+ if (this.aRequestOrigin.scheme === "about" &&
+ this.aRequestOrigin.spec.indexOf("about:neterror?") === 0) {
return true;
}
// If there are entities in the document, they may trigger a local file
// request. We'll only allow requests to .dtd files, though, so we don't
// open up all file:// destinations.
- if (this.aContentLocation.scheme == "file" &&
- this.aContentType == Ci.nsIContentPolicy.TYPE_DTD) {
+ if (this.aContentLocation.scheme === "file" &&
+ this.aContentType === Ci.nsIContentPolicy.TYPE_DTD) {
return true;
}
diff --git a/src/content/lib/ruleset.jsm b/src/content/lib/ruleset.jsm
index 000d139..1e49442 100644
--- a/src/content/lib/ruleset.jsm
+++ b/src/content/lib/ruleset.jsm
@@ -169,7 +169,7 @@ RawRuleset.prototype = {
r.initDestinations();
[rules, r] = this._addEntryHelper(d, r.destinations);
//r.destinationRuleAction = ruleAction;
- if (ruleAction == C.RULE_ACTION_ALLOW) {
+ if (ruleAction === C.RULE_ACTION_ALLOW) {
r.allowDestination = true;
} else {
r.denyDestination = true;
@@ -178,7 +178,7 @@ RawRuleset.prototype = {
} else if (o && !d) {
[rules, r] = this._addEntryHelper(o, policy);
//r.originRuleAction = ruleAction;
- if (ruleAction == C.RULE_ACTION_ALLOW) {
+ if (ruleAction === C.RULE_ACTION_ALLOW) {
r.allowOrigin = true;
} else {
r.denyOrigin = true;
@@ -187,7 +187,7 @@ RawRuleset.prototype = {
} else if (!o && d) {
[rules, r] = this._addEntryHelper(d, policy);
//r.destinationRuleAction = ruleAction;
- if (ruleAction == C.RULE_ACTION_ALLOW) {
+ if (ruleAction === C.RULE_ACTION_ALLOW) {
r.allowDestination = true;
} else {
r.denyDestination = true;
@@ -200,8 +200,8 @@ RawRuleset.prototype = {
},
ruleExists : function(ruleAction, ruleData) {
- var actionStr = ruleAction == C.RULE_ACTION_ALLOW ? "allow" :
- ruleAction == C.RULE_ACTION_DENY ? "deny" : "";
+ var actionStr = ruleAction === C.RULE_ACTION_ALLOW ? "allow" :
+ ruleAction === C.RULE_ACTION_DENY ? "deny" : "";
if (!actionStr) {
throw "Invalid ruleAction: " + ruleAction;
}
@@ -210,7 +210,7 @@ RawRuleset.prototype = {
var entries = this._entries[actionStr];
for (var i in entries) {
var curRuleStr = Ruleset.rawRuleToCanonicalString(entries[i]);
- if (ruleStr == curRuleStr) {
+ if (ruleStr === curRuleStr) {
return true;
}
}
@@ -227,8 +227,8 @@ RawRuleset.prototype = {
addRule : function(ruleAction, ruleData, policy) {
// XXX: remove loggings
//dprint("addRule: adding entry");
- var actionStr = ruleAction == C.RULE_ACTION_ALLOW ? "allow" :
- ruleAction == C.RULE_ACTION_DENY ? "deny" : "";
+ var actionStr = ruleAction === C.RULE_ACTION_ALLOW ? "allow" :
+ ruleAction === C.RULE_ACTION_DENY ? "deny" : "";
if (!actionStr) {
throw "Invalid ruleAction: " + ruleAction;
}
@@ -294,13 +294,13 @@ RawRuleset.prototype = {
return;
}
- // if (r.destinationRuleAction == ruleAction) {
+ // if (r.destinationRuleAction === ruleAction) {
// r.destinationRuleAction = null;
// }
//dprint("_removeEntryFromRuleset: got rule to alter: " + r.toString());
- if (ruleAction == C.RULE_ACTION_ALLOW) {
+ if (ruleAction === C.RULE_ACTION_ALLOW) {
r.allowDestination = null;
- } else if (ruleAction == C.RULE_ACTION_DENY) {
+ } else if (ruleAction === C.RULE_ACTION_DENY) {
r.denyDestination = null;
} else {
throw "Invalid rule type: " + ruleAction;
@@ -321,12 +321,12 @@ RawRuleset.prototype = {
return;
}
- // if (r.originRuleAction == ruleAction) {
+ // if (r.originRuleAction === ruleAction) {
// r.originRuleAction = null;
// }
- if (ruleAction == C.RULE_ACTION_ALLOW) {
+ if (ruleAction === C.RULE_ACTION_ALLOW) {
r.allowOrigin = null;
- } else if (ruleAction == C.RULE_ACTION_DENY) {
+ } else if (ruleAction === C.RULE_ACTION_DENY) {
r.denyOrigin = null;
} else {
throw "Invalid rule type: " + ruleAction;
@@ -347,12 +347,12 @@ RawRuleset.prototype = {
return;
}
- // if (r.destinationRuleAction == ruleAction) {
+ // if (r.destinationRuleAction === ruleAction) {
// r.destinationRuleAction = null;
// }
- if (ruleAction == C.RULE_ACTION_ALLOW) {
+ if (ruleAction === C.RULE_ACTION_ALLOW) {
r.allowDestination = null;
- } else if (ruleAction == C.RULE_ACTION_DENY) {
+ } else if (ruleAction === C.RULE_ACTION_DENY) {
r.denyDestination = null;
} else {
throw "Invalid rule type: " + ruleAction;
@@ -374,8 +374,8 @@ RawRuleset.prototype = {
removeRule : function(ruleAction, ruleData, policy) {
// XXX: remove loggings
//dprint("removeRule: removing entry");
- var actionStr = ruleAction == C.RULE_ACTION_ALLOW ? "allow" :
- ruleAction == C.RULE_ACTION_DENY ? "deny" : "";
+ var actionStr = ruleAction === C.RULE_ACTION_ALLOW ? "allow" :
+ ruleAction === C.RULE_ACTION_DENY ? "deny" : "";
if (!actionStr) {
throw "Invalid ruleAction: " + ruleAction;
}
@@ -384,7 +384,7 @@ RawRuleset.prototype = {
var removeIndex = false;
for (var i in entries) {
var curRuleStr = Ruleset.rawRuleToCanonicalString(entries[i]);
- if (ruleStr == curRuleStr) {
+ if (ruleStr === curRuleStr) {
// |i| is a string which will cause bugs when we use it in arithmetic
// expressions below. Why does this form of iterator give us string
// indexes? I have no idea but it's something to watch out for.
@@ -395,7 +395,7 @@ RawRuleset.prototype = {
if (removeIndex !== false) {
var begin = entries.slice(0, removeIndex);
var end = entries.slice(Number(removeIndex) + 1);
- if (begin.length + end.length + 1 != entries.length) {
+ if (begin.length + end.length + 1 !== entries.length) {
throw "Bad slicing (Probably bad math or not reading the docs).";
}
this._entries[actionStr] = begin.concat(end);
@@ -415,11 +415,12 @@ RawRuleset.prototype = {
for (var actionStr in this._entries) {
//dprint("actionStr: " + actionStr);
- if (actionStr != "allow" && actionStr != "deny") {
+ if (actionStr !== "allow" && actionStr !== "deny") {
dwarn("Invalid entry type: " + actionStr);
continue;
}
- var ruleAction = actionStr == "allow" ? C.RULE_ACTION_ALLOW : C.RULE_ACTION_DENY;
+ var ruleAction = actionStr === "allow" ? C.RULE_ACTION_ALLOW :
+ C.RULE_ACTION_DENY;
var entryArray = this._entries[actionStr];
for (var i in entryArray) {
//dprint("toRuleset: adding entry");
@@ -437,7 +438,7 @@ RawRuleset.prototype = {
if (!("version" in dataObj.metadata)) {
throw "Invalid policy data: no 'version' key";
}
- if (dataObj.metadata.version != 1) {
+ if (dataObj.metadata.version !== 1) {
throw "Wrong metadata version. Expected 1, was " +
dataObj.metadata.version;
}
@@ -499,7 +500,7 @@ Rules.prototype = {
},
isEmpty : function() {
- return this._rules.length == 0;
+ return this._rules.length === 0;
},
[Symbol.iterator] : function*() {
@@ -596,9 +597,9 @@ Rule.prototype = {
},
isEqual : function(otherRule) {
- return this.scheme == otherRule.scheme &&
- this.port == otherRule.port &&
- this.path == otherRule.path;
+ return this.scheme === otherRule.scheme &&
+ this.port === otherRule.port &&
+ this.path === otherRule.path;
},
initDestinations : function() {
@@ -609,7 +610,7 @@ Rule.prototype = {
},
isMatch : function(uriObj) {
- if (this.scheme && this.scheme != uriObj.scheme) {
+ if (this.scheme && this.scheme !== uriObj.scheme) {
//dprint("isMatch: wrong scheme (uri: '" + uriObj.scheme + "', rule: '" +
// this.scheme + "')");
return false;
@@ -634,8 +635,8 @@ Rule.prototype = {
}
if (this.path) {
- if (typeof this.path == "string") {
- if (uriObj.path.indexOf(this.path) != 0) {
+ if (typeof this.path === "string") {
+ if (uriObj.path.indexOf(this.path) !== 0) {
//dprint("isMatch: wrong path (string): " + this.path + " vs " + uriObj.path);
return false;
}
@@ -1080,13 +1081,13 @@ Ruleset.matchToRawRule = function(match) {
var entry, rule, destEntry, destRule;
var actionStr = match[0];
- if (actionStr == "origin") {
+ if (actionStr === "origin") {
[actionStr, entry, rule] = match;
Ruleset._matchToRawRuleHelper(rawRule, "o", entry, rule);
- } else if (actionStr == "dest") {
+ } else if (actionStr === "dest") {
[actionStr, entry, rule] = match;
Ruleset._matchToRawRuleHelper(rawRule, "d", entry, rule);
- } else if (actionStr == "origin-to-dest") {
+ } else if (actionStr === "origin-to-dest") {
[actionStr, entry, rule, destEntry, destRule] = match;
Ruleset._matchToRawRuleHelper(rawRule, "o", entry, rule);
Ruleset._matchToRawRuleHelper(rawRule, "d", destEntry, destRule);
@@ -1149,5 +1150,5 @@ Ruleset.rawRuleToCanonicalString = function(rawRule) {
// Ruleset.rawRulesAreEqual = function(first, second) {
// var firstStr = Ruleset.rawRuleToCanonicalString(first);
// var secondStr = Ruleset.rawRuleToCanonicalString(second);
-// return firstStr == secondStr;
+// return firstStr === secondStr;
// }
diff --git a/src/content/lib/subscription.jsm b/src/content/lib/subscription.jsm
index bdc3481..44252e5 100644
--- a/src/content/lib/subscription.jsm
+++ b/src/content/lib/subscription.jsm
@@ -204,18 +204,18 @@ UserSubscriptions.prototype = {
dprint('Skipping update of unsubscribed subscription: ' + listName + ' ' + subName);
continue;
}
- if (defaultPolicy == 'allow' && subName.indexOf('allow_') == 0) {
+ if (defaultPolicy === 'allow' && subName.indexOf('allow_') === 0) {
dprint('Skipping update of subscription that is only used with a default deny policy: ' + subName);
continue;
}
- if (defaultPolicy == 'deny' && subName.indexOf('deny_') == 0) {
+ if (defaultPolicy === 'deny' && subName.indexOf('deny_') === 0) {
dprint('Skipping update of subscription that is only used with a default allow policy: ' + subName);
continue;
}
updateSubs[subName] = {'serial' : serials[listName][subName]};
subCount++;
}
- if (subCount == 0) {
+ if (subCount === 0) {
dprint('Skipping list with no subscriptions: ' + listName);
continue;
}
@@ -262,7 +262,7 @@ UserSubscriptions.prototype = {
list.updateMetadata(metadataSuccess, metadataError);
}
- if (listCount == 0) {
+ if (listCount === 0) {
dprint('No lists to update.');
setTimeout(function () { callback(updateResults); }, 0);
}
@@ -428,7 +428,7 @@ Subscription.prototype = {
}, 0);
return;
}
- if (typeof serial != 'number' || serial % 1 != 0) {
+ if (typeof serial !== 'number' || serial % 1 !== 0) {
let error = 'Ruleset has invalid serial number: ' + serial;
setTimeout(function () {
errorCallback(self, error);
diff --git a/src/content/lib/utils/domains.jsm b/src/content/lib/utils/domains.jsm
index 6413738..4704811 100644
--- a/src/content/lib/utils/domains.jsm
+++ b/src/content/lib/utils/domains.jsm
@@ -95,9 +95,9 @@ DomainUtil.getIdentifier = function(uri, level) {
if (identifier) {
return identifier;
} else {
- if (uri.indexOf("file://") == 0) {
+ if (uri.indexOf("file://") === 0) {
return "file://";
- } else if (uri.indexOf("data:") == 0) {
+ } else if (uri.indexOf("data:") === 0) {
// Format: data:[<MIME-type>][;charset=<encoding>][;base64],<data>
identifier = uri.split(",")[0];
return identifier.split(";")[0];
@@ -199,9 +199,9 @@ DomainUtil.getBaseDomain = function(uri) {
// the result is ASCII/ACE encoded, false otherwise.
return DomainUtil._idnService.convertToDisplayIDN(baseDomain, {});
} catch (e) {
- if (e.name == "NS_ERROR_HOST_IS_IP_ADDRESS") {
+ if (e.name === "NS_ERROR_HOST_IS_IP_ADDRESS") {
return host;
- } else if (e.name == "NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS") {
+ } else if (e.name === "NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS") {
return host;
} else {
throw e;
@@ -220,7 +220,7 @@ DomainUtil.isIPAddress = function(host) {
try {
Services.eTLD.getBaseDomainFromHost(host, 0);
} catch (e) {
- if (e.name == "NS_ERROR_HOST_IS_IP_ADDRESS") {
+ if (e.name === "NS_ERROR_HOST_IS_IP_ADDRESS") {
return true;
}
}
@@ -272,14 +272,14 @@ DomainUtil.parseRefresh = function(refreshString) {
throw "Invalid delay value in refresh string: " + parts[1];
}
var url = parts[3];
- if (url == undefined) {
+ if (url === undefined) {
url = '';
}
// Strip off enclosing quotes around the url.
if (url) {
var first = url[0];
var last = url[url.length - 1];
- if (first == last && (first == "'" || first == '"')) {
+ if (first === last && (first === "'" || first === '"')) {
url = url.substring(1, url.length - 1);
}
}
@@ -349,8 +349,8 @@ DomainUtil.determineRedirectUri = function(originUri, destPath) {
*/
DomainUtil.hasStandardPort = function(uri) {
// A port value of -1 in the uriObj means the default for the protocol.
- return uri.port == -1 ||
- uri.scheme != "http" && uri.scheme != "https" ||
- uri.port == 80 && uri.scheme == "http" ||
- uri.port == 443 && uri.scheme == "https";
-}
+ return uri.port === -1 ||
+ uri.scheme !== "http" && uri.scheme !== "https" ||
+ uri.port === 80 && uri.scheme === "http" ||
+ uri.port === 443 && uri.scheme === "https";
+};
diff --git a/src/content/lib/utils/files.jsm b/src/content/lib/utils/files.jsm
index 8cf4127..19210dd 100644
--- a/src/content/lib/utils/files.jsm
+++ b/src/content/lib/utils/files.jsm
@@ -116,7 +116,7 @@ var FileUtil = {
// Read as much as we can and put it in |data.value|.
read = cstream.readString(0xffffffff, data);
str += data.value;
- } while (read != 0);
+ } while (read !== 0);
cstream.close(); // This closes |fstream|.
return str;
diff --git a/src/content/lib/utils/info.jsm b/src/content/lib/utils/info.jsm
index 006b5ae..19cda2b 100644
--- a/src/content/lib/utils/info.jsm
+++ b/src/content/lib/utils/info.jsm
@@ -60,7 +60,7 @@ var Info = (function() {
AddonManager.getAddonByID(C.EXTENSION_ID, function(addon) {
rpPrefBranch.setCharPref("lastVersion", addon.version);
self.curRPVersion = addon.version;
- if (self.lastRPVersion != self.curRPVersion) {
+ if (self.lastRPVersion !== self.curRPVersion) {
Services.prefs.savePrefFile(null);
}
});
@@ -75,7 +75,7 @@ var Info = (function() {
self.curAppVersion = curAppVersion;
rpPrefBranch.setCharPref("lastAppVersion", curAppVersion);
- if (self.lastAppVersion != self.curAppVersion) {
+ if (self.lastAppVersion !== self.curAppVersion) {
Services.prefs.savePrefFile(null);
}
}
diff --git a/src/content/main/pref-manager.jsm b/src/content/main/pref-manager.jsm
index b0523ec..63fdd69 100644
--- a/src/content/main/pref-manager.jsm
+++ b/src/content/main/pref-manager.jsm
@@ -137,7 +137,7 @@ var PrefManager = (function() {
function maybeHandleUninstallOrDisable(data, reason) {
- if (reason == C.ADDON_DISABLE || reason == C.ADDON_UNINSTALL) {
+ if (reason === C.ADDON_DISABLE || reason === C.ADDON_UNINSTALL) {
// TODO: Handle uninstallation in bootstrap.js, not here, RP might be
// disabled when being uninstalled.
handleUninstallOrDisable();
diff --git a/src/content/main/requestpolicy-service.jsm b/src/content/main/requestpolicy-service.jsm
index b6fb476..8ed15d0 100644
--- a/src/content/main/requestpolicy-service.jsm
+++ b/src/content/main/requestpolicy-service.jsm
@@ -332,7 +332,7 @@ var rpService = (function() {
// support for old browsers (Firefox <20)
case "private-browsing" :
- if (data == "exit") {
+ if (data === "exit") {
PolicyManager.revokeTemporaryRules();
}
break;
diff --git a/src/content/main/window-manager.listener.js b/src/content/main/window-manager.listener.js
index 7adb5a0..0095d9f 100644
--- a/src/content/main/window-manager.listener.js
+++ b/src/content/main/window-manager.listener.js
@@ -53,7 +53,7 @@ var WindowListener = (function() {
listeners[winID][eventName] !== null) {
listeners[winID].window.removeEventListener(eventName,
listeners[winID][eventName]);
- if (eventName == 'unload') {
+ if (eventName === "unload") {
// when removing the 'unload' listener, also remove the 'load'
// listener and then delete listener[winID].
removeEvLis("load", winID);
@@ -85,8 +85,8 @@ var WindowListener = (function() {
// ----------------------------------------------
let onLoad = function(event) {
removeEvLis("load", winID);
-
- if (window.document.documentElement.getAttribute("windowtype") ==
+
+ if (window.document.documentElement.getAttribute("windowtype") ===
"navigator:browser") {
if (!!externalLoadFunction) {
externalLoadFunction(window);
@@ -98,7 +98,7 @@ var WindowListener = (function() {
let onUnload = function(event) {
removeEvLis("unload", onUnload);
- if (window.document.documentElement.getAttribute("windowtype") ==
+ if (window.document.documentElement.getAttribute("windowtype") ===
"navigator:browser") {
if (!!externalUnloadFunction) {
externalUnloadFunction(window);
diff --git a/src/content/ui/frame.js b/src/content/ui/frame.js
index e54cb53..d18f838 100644
--- a/src/content/ui/frame.js
+++ b/src/content/ui/frame.js
@@ -100,7 +100,7 @@
// * left-clicks
// * enter key while focused
// * space bar while focused (no event sent for links in this case)
- if (event.button != 0) {
+ if (event.button !== 0) {
return;
}
// Link clicked.
diff --git a/src/content/ui/menu.js b/src/content/ui/menu.js
index cb285c8..1f95f5e 100644
--- a/src/content/ui/menu.js
+++ b/src/content/ui/menu.js
@@ -308,7 +308,7 @@ window.rpcontinued.menu = (function () {
self._populateOtherOrigins = function() {
let guiOrigins = self._getOtherOriginsAsGUILocations();
self._populateList(lists.otherOrigins, guiOrigins);
- $id('rpc-other-origins').hidden = guiOrigins.length == 0;
+ $id('rpc-other-origins').hidden = guiOrigins.length === 0;
};
self._populateDestinations = function(originIdentifier) {
@@ -338,10 +338,10 @@ window.rpcontinued.menu = (function () {
let destsMixedIndex = GUIDestination.
indexOfDestInArray(allowedGUIDest, destsMixed);
- if (indexRawBlocked == -1) {
+ if (indexRawBlocked === -1) {
destsWithSolelyAllowedRequests.push(allowedGUIDest);
} else {
- if (destsMixedIndex != -1) {
+ if (destsMixedIndex !== -1) {
Logger.info(Logger.TYPE_INTERNAL,
"Merging dest: <" + allowedGUIDest + ">");
destsMixed[destsMixedIndex] = GUIDestination.merge(
@@ -361,15 +361,15 @@ window.rpcontinued.menu = (function () {
self._populateList(lists.blockedDestinations,
destsWithSolelyBlockedRequests);
$id('rpc-blocked-destinations').hidden =
- destsWithSolelyBlockedRequests.length == 0;
+ destsWithSolelyBlockedRequests.length === 0;
self._populateList(lists.mixedDestinations, destsMixed);
- $id('rpc-mixed-destinations').hidden = destsMixed.length == 0;
+ $id('rpc-mixed-destinations').hidden = destsMixed.length === 0;
self._populateList(lists.allowedDestinations,
destsWithSolelyAllowedRequests);
$id('rpc-allowed-destinations').hidden =
- destsWithSolelyAllowedRequests.length == 0;
+ destsWithSolelyAllowedRequests.length === 0;
};
self._populateDetails = function() {
@@ -718,7 +718,7 @@ window.rpcontinued.menu = (function () {
// requests to the same domain:
// Ignore the selected origin's domain when listing destinations.
if (Prefs.isDefaultAllow() || Prefs.isDefaultAllowSameDomain()) {
- if (destBase == self._currentlySelectedOrigin) {
+ if (destBase === self._currentlySelectedOrigin) {
continue;
}
}
@@ -779,7 +779,7 @@ window.rpcontinued.menu = (function () {
var guiOriginsIndex = GUIOrigin.indexOfOriginInArray(originBase,
guiOrigins);
var properties;
- if (guiOriginsIndex == -1) {
+ if (guiOriginsIndex === -1) {
properties = new GUILocationProperties();
} else {
properties = guiOrigins[guiOriginsIndex].properties;
@@ -795,14 +795,14 @@ window.rpcontinued.menu = (function () {
// guiOrigins to the same domain:
// Only list other origins where there is a destination from that origin
// that is at a different domain, not just a different subdomain.
- if (allowSameDomain && destBase == originBase) {
+ if (allowSameDomain && destBase === originBase) {
continue;
}
addThisOriginBase = true;
properties.accumulate(allRequests[originUri][destBase]);
}
- if (addThisOriginBase && guiOriginsIndex == -1) {
+ if (addThisOriginBase && guiOriginsIndex === -1) {
guiOrigins.push(new GUIOrigin(originBase, properties));
}
}
@@ -811,7 +811,7 @@ window.rpcontinued.menu = (function () {
self._isIPAddressOrSingleName = function(hostname) {
return DomainUtil.isIPAddress(hostname) ||
- hostname.indexOf(".") == -1;
+ hostname.indexOf(".") === -1;
};
self._addWildcard = function(hostname) {
@@ -1035,7 +1035,7 @@ window.rpcontinued.menu = (function () {
for (let destBase in requests) {
if (self._currentlySelectedDest &&
- self._currentlySelectedDest != destBase) {
+ self._currentlySelectedDest !== destBase) {
continue;
}
@@ -1118,7 +1118,7 @@ window.rpcontinued.menu = (function () {
for (let destBase in requests) {
if (self._currentlySelectedDest &&
- self._currentlySelectedDest != destBase) {
+ self._currentlySelectedDest !== destBase) {
continue;
}
@@ -1191,7 +1191,7 @@ window.rpcontinued.menu = (function () {
for (let destBase in requests) {
if (self._currentlySelectedDest &&
- self._currentlySelectedDest != destBase) {
+ self._currentlySelectedDest !== destBase) {
continue;
}
for (let destIdent in requests[destBase]) {
diff --git a/src/content/ui/request-log.interface.js b/src/content/ui/request-log.interface.js
index c8faeaa..1aa74e3 100644
--- a/src/content/ui/request-log.interface.js
+++ b/src/content/ui/request-log.interface.js
@@ -40,7 +40,7 @@ window.rpcontinued.requestLog = (function (self) {
self.clear = function() {
var count = self.treeView.rowCount;
- if (count == 0) {
+ if (count === 0) {
return;
}
self.rows = [];
diff --git a/src/content/ui/request-log.tree-view.js b/src/content/ui/request-log.tree-view.js
index 0748b1d..5252ca4 100644
--- a/src/content/ui/request-log.tree-view.js
+++ b/src/content/ui/request-log.tree-view.js
@@ -76,7 +76,7 @@ window.rpcontinued.requestLog = (function (self) {
// TODO: Do an actual speed test with push vs. unshift to see if it matters
// with this javascript array implementation, though I'm assuming it does.
var columnIndex = self.columnNameToIndexMap[aColumn.id];
- if (columnIndex != 2) {
+ if (columnIndex !== 2) {
return getVisibleRowAtIndex(aIndex)[self.columnNameToIndexMap[aColumn.id]];
}
},
@@ -120,7 +120,7 @@ window.rpcontinued.requestLog = (function (self) {
toggleOpenState: function(aIndex) {},
getImageSrc: function(aIndex, aColumn) {
- if (self.columnNameToIndexMap[aColumn.id] == 2) {
+ if (self.columnNameToIndexMap[aColumn.id] === 2) {
if (getVisibleRowAtIndex(aIndex)[2]) {
return "chrome://rpcontinued/skin/dot.png";
}
@@ -140,7 +140,7 @@ window.rpcontinued.requestLog = (function (self) {
},
getCellProperties: function(aIndex, aColumn) {
- if (self.columnNameToIndexMap[aColumn.id] == 2) {
+ if (self.columnNameToIndexMap[aColumn.id] === 2) {
if (getVisibleRowAtIndex(aIndex)[2]) {
return "blocked";
}
--
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