[Pkg-mozext-commits] [requestpolicy] 166/257: [ref] use "let" in many places
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 bc74b527c8351a2017d5a3baea4d9212e7e72180
Author: Martin Kimmerle <dev at 256k.de>
Date: Tue Dec 1 15:01:20 2015 +0100
[ref] use "let" in many places
---
src/content/lib/policy-manager.jsm | 44 ++++----
src/content/lib/request-processor.compat.js | 6 +-
src/content/lib/request-processor.jsm | 54 ++++-----
src/content/lib/request-processor.redirects.js | 53 ++++-----
src/content/lib/ruleset-storage.jsm | 5 +-
src/content/lib/ruleset.jsm | 14 +--
src/content/lib/subscription.jsm | 8 +-
src/content/main/requestpolicy-service.jsm | 52 ++++-----
src/content/ui/menu.js | 148 ++++++++++++-------------
9 files changed, 194 insertions(+), 190 deletions(-)
diff --git a/src/content/lib/policy-manager.jsm b/src/content/lib/policy-manager.jsm
index dd2c935..30bc60d 100644
--- a/src/content/lib/policy-manager.jsm
+++ b/src/content/lib/policy-manager.jsm
@@ -113,12 +113,12 @@ var PolicyManager = (function () {
};
self.loadSubscriptionRules = function(subscriptionInfo) {
- var failures = {};
+ let failures = {};
// Read each subscription from a file.
- var rawRuleset;
- for (var listName in subscriptionInfo) {
- for (var subName in subscriptionInfo[listName]) {
+ let rawRuleset;
+ for (let listName in subscriptionInfo) {
+ for (let subName in subscriptionInfo[listName]) {
try {
dprint("PolicyManager::loadSubscriptionRules: " +
listName + ' / ' + subName);
@@ -135,7 +135,7 @@ var PolicyManager = (function () {
if (!subscriptionRulesets[listName]) {
subscriptionRulesets[listName] = {};
}
- var list = subscriptionRulesets[listName];
+ let list = subscriptionRulesets[listName];
list[subName] = {
"rawRuleset" : rawRuleset,
"ruleset" : rawRuleset.toRuleset(subName)
@@ -153,8 +153,8 @@ var PolicyManager = (function () {
self.unloadSubscriptionRules = function(subscriptionInfo) {
var failures = {};
- for (var listName in subscriptionInfo) {
- for (var subName in subscriptionInfo[listName]) {
+ for (let listName in subscriptionInfo) {
+ for (let subName in subscriptionInfo[listName]) {
dprint("PolicyManager::unloadSubscriptionRules: " +
listName + ' / ' + subName);
if (!subscriptionRulesets[listName] ||
@@ -165,7 +165,7 @@ var PolicyManager = (function () {
failures[listName][subName] = null;
continue;
}
- var list = subscriptionRulesets[listName];
+ let list = subscriptionRulesets[listName];
delete list[subName];
}
}
@@ -183,14 +183,14 @@ var PolicyManager = (function () {
self.ruleExists = function(ruleAction, ruleData) {
assertRuleAction(ruleAction);
- for (var name in userRulesets) {
+ for (let name in userRulesets) {
if (userRulesets[name].rawRuleset.ruleExists(ruleAction, ruleData)) {
return true;
}
}
- for (var listName in subscriptionRulesets) {
- var rulesets = subscriptionRulesets[listName];
- for (var name in rulesets) {
+ for (let listName in subscriptionRulesets) {
+ let rulesets = subscriptionRulesets[listName];
+ for (let name in rulesets) {
if (rulesets[name].rawRuleset.ruleExists(ruleAction, ruleData)) {
return true;
}
@@ -305,8 +305,8 @@ var PolicyManager = (function () {
self.checkRequestAgainstSubscriptionRules = function(origin, dest) {
var result = new RequestResult();
- for (var listName in subscriptionRulesets) {
- var ruleset = subscriptionRulesets[listName];
+ for (let listName in subscriptionRulesets) {
+ let ruleset = subscriptionRulesets[listName];
checkRequest(origin, dest, ruleset, result);
}
return result;
@@ -322,20 +322,20 @@ var PolicyManager = (function () {
if (!result) {
result = new RequestResult();
}
- for (var i in aRuleset) {
- var ruleset = aRuleset[i].ruleset;
+ for (let name in aRuleset) {
+ let {ruleset} = aRuleset[name];
//ruleset.setPrintFunction(print);
//ruleset.print();
- var tempAllow, tempDeny;
+
// TODO wrap this in a try/catch.
- [tempAllow, tempDeny] = ruleset.check(origin, dest);
+ let [tempAllows, tempDenies] = ruleset.check(origin, dest);
// I'm not convinced I like appending these [ruleset, matchedRule] arrays,
// but it works for now.
- for (var i in tempAllow) {
- result.matchedAllowRules.push([ruleset, tempAllow[i]]);
+ for (let tempAllow of tempAllows) {
+ result.matchedAllowRules.push([ruleset, tempAllow]);
}
- for (var i in tempDeny) {
- result.matchedDenyRules.push([ruleset, tempDeny[i]]);
+ for (let tempDeny of tempDenies) {
+ result.matchedDenyRules.push([ruleset, tempDeny]);
}
}
return result;
diff --git a/src/content/lib/request-processor.compat.js b/src/content/lib/request-processor.compat.js
index ee7f778..cb1d0f8 100644
--- a/src/content/lib/request-processor.compat.js
+++ b/src/content/lib/request-processor.compat.js
@@ -89,9 +89,9 @@ RequestProcessor = (function(self) {
idArray.push("FirefoxAddon at similarWeb.com"); // SimilarWeb
idArray.push("{6614d11d-d21d-b211-ae23-815234e1ebb5}"); // Dr. Web Link Checker
- for (let i in idArray) {
- Logger.info(Logger.TYPE_INTERNAL, "Extension check: " + idArray[i]);
- AddonManager.getAddonByID(idArray[i], initializeExtCompatCallback);
+ for (let id of idArray) {
+ Logger.info(Logger.TYPE_INTERNAL, "Extension check: " + id);
+ AddonManager.getAddonByID(id, initializeExtCompatCallback);
}
}
diff --git a/src/content/lib/request-processor.jsm b/src/content/lib/request-processor.jsm
index 7dbac38..15d18f9 100644
--- a/src/content/lib/request-processor.jsm
+++ b/src/content/lib/request-processor.jsm
@@ -315,20 +315,23 @@ var RequestProcessor = (function () {
// We're assuming ident is fullIdent (LEVEL_SOP). We plan to remove base
// domain and hostname levels.
- for (var originUri in requests) {
+ for (let originUri in requests) {
if (DomainUtil.getBaseDomain(originUri) !== currentlySelectedOrigin) {
// only return requests from the given base domain
continue;
}
- Logger.dump("test destBase: " + destBase);
- for (var destBase in requests[originUri]) {
+ Logger.dump("test originUri: " + originUri);
+ let originUriRequests = requests[originUri];
+ for (let destBase in originUriRequests) {
Logger.dump("test destBase: " + destBase);
- for (var destIdent in requests[originUri][destBase]) {
+ let destBaseRequests = originUriRequests[destBase];
+ for (let destIdent in destBaseRequests) {
Logger.dump("test destIdent: " + destIdent);
- for (var destUri in requests[originUri][destBase][destIdent]) {
+ let destIdentRequests = destBaseRequests[destIdent];
+ for (let destUri in destIdentRequests) {
Logger.dump("test destUri: " + destUri);
- var dest = requests[originUri][destBase][destIdent][destUri];
- for (var i in dest) {
+ let dest = destIdentRequests[destUri];
+ for (let i in dest) {
// TODO: This variable could have been created easily already in
// getAllRequestsInBrowser(). ==> rewrite RequestSet to
// contain a blocked list, an allowed list (and maybe a list
@@ -520,8 +523,8 @@ var RequestProcessor = (function () {
}
}
- if (request.aRequestOrigin.scheme == "view-source") {
- var newOriginURI = originURI.split(":").slice(1).join(":");
+ if (request.aRequestOrigin.scheme === "view-source") {
+ let newOriginURI = originURI.split(":").slice(1).join(":");
Logger.info(Logger.TYPE_CONTENT,
"Considering view-source origin <" + originURI + "> " +
"to be origin <" + newOriginURI + ">");
@@ -552,7 +555,7 @@ var RequestProcessor = (function () {
domNode = request.aContext.QueryInterface(Ci.nsIDOMNode);
} catch (e if e.result == Cr.NS_ERROR_NO_INTERFACE) {}
if (domNode && domNode.nodeType == Ci.nsIDOMNode.DOCUMENT_NODE) {
- var newOriginURI;
+ let newOriginURI;
if (request.aContext.documentURI &&
request.aContext.documentURI != "about:blank") {
newOriginURI = request.aContext.documentURI;
@@ -739,13 +742,13 @@ var RequestProcessor = (function () {
request.requestResult = PolicyManager.checkRequestAgainstUserRules(
request.aRequestOrigin, request.aContentLocation);
- for (var i = 0; i < request.requestResult.matchedDenyRules.length; i++) {
+ for (let matchedDenyRule of request.requestResult.matchedDenyRules) {
Logger.dump('Matched deny rules');
- Logger.vardump(request.requestResult.matchedDenyRules[i]);
+ Logger.vardump(matchedDenyRule);
}
- for (var i = 0; i < request.requestResult.matchedAllowRules.length; i++) {
+ for (let matchedAllowRule of request.requestResult.matchedAllowRules) {
Logger.dump('Matched allow rules');
- Logger.vardump(request.requestResult.matchedAllowRules[i]);
+ Logger.vardump(matchedAllowRule);
}
// If there are both allow and deny rules, then fall back on the default
// policy. I believe this is effectively the same as giving precedence
@@ -783,15 +786,13 @@ var RequestProcessor = (function () {
request.requestResult = PolicyManager
.checkRequestAgainstSubscriptionRules(request.aRequestOrigin,
request.aContentLocation);
- for (var i = 0; i < request.requestResult.matchedDenyRules.length; i++) {
+ for (let matchedDenyRule of request.requestResult.matchedDenyRules) {
Logger.dump('Matched deny rules');
- Logger.vardump(
- request.requestResult.matchedDenyRules[i]);
+ Logger.vardump(matchedDenyRule);
}
- for (var i = 0; i < request.requestResult.matchedAllowRules.length; i++) {
+ for (let matchedAllowRule of request.requestResult.matchedAllowRules) {
Logger.dump('Matched allow rules');
- Logger.vardump(
- request.requestResult.matchedAllowRules[i]);
+ Logger.vardump(matchedAllowRule);
}
if (request.requestResult.allowRulesExist() &&
request.requestResult.denyRulesExist()) {
@@ -822,10 +823,9 @@ var RequestProcessor = (function () {
}
let compatibilityRules = self.getCompatibilityRules();
- for (var i = 0; i < compatibilityRules.length; i++) {
- var rule = compatibilityRules[i];
- var allowOrigin = rule[0] ? originURI.indexOf(rule[0]) == 0 : true;
- var allowDest = rule[1] ? destURI.indexOf(rule[1]) == 0 : true;
+ for (let rule of compatibilityRules) {
+ let allowOrigin = rule[0] ? originURI.indexOf(rule[0]) === 0 : true;
+ let allowDest = rule[1] ? destURI.indexOf(rule[1]) === 0 : true;
if (allowOrigin && allowDest) {
request.requestResult = new RequestResult(true,
REQUEST_REASON_COMPATIBILITY);
@@ -841,11 +841,11 @@ var RequestProcessor = (function () {
// Check aExtra against CP_MAPPEDDESTINATION to stop further recursion.
if (request.aExtra != CP_MAPPEDDESTINATION &&
internal.mappedDestinations[destURI]) {
- for (var mappedDest in internal.mappedDestinations[destURI]) {
+ for (let mappedDest in internal.mappedDestinations[destURI]) {
var mappedDestUriObj = internal.mappedDestinations[destURI][mappedDest];
Logger.warning(Logger.TYPE_CONTENT,
"Checking mapped destination: " + mappedDest);
- var mappedResult = PolicyImplementation.shouldLoad(
+ let mappedResult = PolicyImplementation.shouldLoad(
request.aContentType, mappedDestUriObj, request.aRequestOrigin,
request.aContext, request.aMimeTypeGuess, CP_MAPPEDDESTINATION);
if (mappedResult == CP_OK) {
@@ -1024,7 +1024,7 @@ var RequestProcessor = (function () {
* @param {Object} observer
*/
self.removeRequestObserver = function(observer) {
- for (var i = 0; i < internal.requestObservers.length; i++) {
+ for (let i = 0; i < internal.requestObservers.length; i++) {
if (internal.requestObservers[i] == observer) {
Logger.debug(Logger.TYPE_INTERNAL,
"Removing request observer: " + observer.toString());
diff --git a/src/content/lib/request-processor.redirects.js b/src/content/lib/request-processor.redirects.js
index 26218eb..92562e9 100644
--- a/src/content/lib/request-processor.redirects.js
+++ b/src/content/lib/request-processor.redirects.js
@@ -116,28 +116,32 @@ RequestProcessor = (function(self) {
var originURIObj = DomainUtil.getUriObject(originURI);
var destURIObj = DomainUtil.getUriObject(destURI);
- var result = PolicyManager.checkRequestAgainstUserRules(originURIObj,
- destURIObj);
- // For now, we always give priority to deny rules.
- if (result.denyRulesExist()) {
- result.isAllowed = false;
- return result;
- }
- if (result.allowRulesExist()) {
- result.isAllowed = true;
- return result;
+ {
+ let result = PolicyManager.checkRequestAgainstUserRules(originURIObj,
+ destURIObj);
+ // For now, we always give priority to deny rules.
+ if (result.denyRulesExist()) {
+ result.isAllowed = false;
+ return result;
+ }
+ if (result.allowRulesExist()) {
+ result.isAllowed = true;
+ return result;
+ }
}
- var result = PolicyManager.checkRequestAgainstSubscriptionRules(
- originURIObj, destURIObj);
- // For now, we always give priority to deny rules.
- if (result.denyRulesExist()) {
- result.isAllowed = false;
- return result;
- }
- if (result.allowRulesExist()) {
- result.isAllowed = true;
- return result;
+ {
+ let result = PolicyManager.checkRequestAgainstSubscriptionRules(
+ originURIObj, destURIObj);
+ // For now, we always give priority to deny rules.
+ if (result.denyRulesExist()) {
+ result.isAllowed = false;
+ return result;
+ }
+ if (result.allowRulesExist()) {
+ result.isAllowed = true;
+ return result;
+ }
}
// fixme: "//example.com/path" is also a valid relative URL
@@ -148,16 +152,15 @@ RequestProcessor = (function(self) {
}
let compatibilityRules = self.getCompatibilityRules();
- for (var i = 0; i < compatibilityRules.length; i++) {
- var rule = compatibilityRules[i];
- var allowOrigin = rule[0] ? originURI.indexOf(rule[0]) == 0 : true;
- var allowDest = rule[1] ? destURI.indexOf(rule[1]) == 0 : true;
+ for (let rule of compatibilityRules) {
+ let allowOrigin = rule[0] ? originURI.indexOf(rule[0]) === 0 : true;
+ let allowDest = rule[1] ? destURI.indexOf(rule[1]) === 0 : true;
if (allowOrigin && allowDest) {
return new RequestResult(true, REQUEST_REASON_COMPATIBILITY);
}
}
- var result = internal.checkByDefaultPolicy(originURI, destURI);
+ let result = internal.checkByDefaultPolicy(originURI, destURI);
return result;
}
diff --git a/src/content/lib/ruleset-storage.jsm b/src/content/lib/ruleset-storage.jsm
index eec6a94..01145cd 100644
--- a/src/content/lib/ruleset-storage.jsm
+++ b/src/content/lib/ruleset-storage.jsm
@@ -77,11 +77,12 @@ var RulesetStorage = (function() {
subscriptionListName) {
// TODO: change filename argument to policyname and we'll append the '.json'
// TODO: get a stream and use the mozilla json interface to encode to stream.
+ let policyFile;
if (subscriptionListName) {
- var policyFile = FileUtil.getRPUserDir("policies",
+ policyFile = FileUtil.getRPUserDir("policies",
'subscriptions', subscriptionListName);
} else {
- var policyFile = FileUtil.getRPUserDir("policies");
+ policyFile = FileUtil.getRPUserDir("policies");
}
policyFile.appendRelativePath(filename);
FileUtil.stringToFile(JSON.stringify(policy), policyFile);
diff --git a/src/content/lib/ruleset.jsm b/src/content/lib/ruleset.jsm
index bbb19ec..000d139 100644
--- a/src/content/lib/ruleset.jsm
+++ b/src/content/lib/ruleset.jsm
@@ -941,11 +941,11 @@ Ruleset.prototype = {
//dprint("Checking origin rules and origin-to-destination rules.");
// First, check for rules for each part of the origin host.
- originouterloop: for (var entry in this.getHostMatches(originHost)) {
+ originouterloop: for (let entry in this.getHostMatches(originHost)) {
//dprint(entry);
- for (var rule of entry.rules) {
+ for (let rule of entry.rules) {
//dprint("Checking rule: " + rule);
- var ruleMatchedOrigin = rule.isMatch(origin);
+ let ruleMatchedOrigin = rule.isMatch(origin);
if (rule.allowOrigin && ruleMatchedOrigin) {
//dprint("ALLOW origin by rule " + entry + " " + rule);
@@ -975,9 +975,9 @@ Ruleset.prototype = {
// entry we're currently looking at.
if (ruleMatchedOrigin && rule.destinations) {
//dprint("There are origin-to-destination rules using this origin rule.");
- for (var destEntry in rule.destinations.getHostMatches(destHost)) {
+ for (let destEntry in rule.destinations.getHostMatches(destHost)) {
//dprint(destEntry);
- for (var destRule of destEntry.rules) {
+ for (let destRule of destEntry.rules) {
//dprint("Checking rule: " + rule);
if (destRule.allowDestination && destRule.isMatch(dest)) {
//dprint("ALLOW origin-to-dest by rule origin " + entry + " " + rule + " to dest " + destEntry + " " + destRule);
@@ -1013,9 +1013,9 @@ Ruleset.prototype = {
//dprint("Checking dest rules.");
// Last, check for rules for each part of the destination host.
- destouterloop: for (var entry in this.getHostMatches(destHost)) {
+ destouterloop: for (let entry in this.getHostMatches(destHost)) {
//dprint(entry);
- for (var rule of entry.rules) {
+ for (let rule of entry.rules) {
//dprint("Checking rule: " + rule);
if (rule.allowDestination && rule.isMatch(dest)) {
//dprint("ALLOW dest by rule " + entry + " " + rule);
diff --git a/src/content/lib/subscription.jsm b/src/content/lib/subscription.jsm
index 64cfb83..bdc3481 100644
--- a/src/content/lib/subscription.jsm
+++ b/src/content/lib/subscription.jsm
@@ -323,7 +323,7 @@ SubscriptionList.prototype = {
},
updateSubscriptions : function (userSubs, successCallback, errorCallback) {
- for (var subName in userSubs) {
+ for (let subName in userSubs) {
let sub;
try {
var serial = this.getSubscriptionSerial(subName);
@@ -408,8 +408,10 @@ Subscription.prototype = {
try {
self._rawData = req.responseText;
if (!self._rawData) {
- var error = 'Empty response when requesting subscription file';
- setTimeout(function () { errorCallback(self, error); }, 0);
+ let error = 'Empty response when requesting subscription file';
+ setTimeout(function () {
+ errorCallback(self, error);
+ }, 0);
return;
}
self._data = JSON.parse(req.responseText);
diff --git a/src/content/main/requestpolicy-service.jsm b/src/content/main/requestpolicy-service.jsm
index c93d5d8..b6fb476 100644
--- a/src/content/main/requestpolicy-service.jsm
+++ b/src/content/main/requestpolicy-service.jsm
@@ -63,29 +63,29 @@ var rpService = (function() {
subscriptions = new UserSubscriptions();
PolicyManager.loadUserRules();
- var defaultPolicy = Prefs.isDefaultAllow() ? "allow" : "deny";
+ let defaultPolicy = Prefs.isDefaultAllow() ? "allow" : "deny";
- var failures = PolicyManager.loadSubscriptionRules(
- subscriptions.getSubscriptionInfo(defaultPolicy));
+ let failures = PolicyManager.loadSubscriptionRules(
+ subscriptions.getSubscriptionInfo(defaultPolicy));
// TODO: check a preference that indicates the last time we checked for
// updates. Don't do it if we've done it too recently.
// TODO: Maybe we should probably ship snapshot versions of the official
// rulesets so that they can be available immediately after installation.
- var serials = {};
- for (var listName in failures) {
+ let serials = {};
+ for (let listName in failures) {
serials[listName] = {};
- for (var subName in failures[listName]) {
+ for (let subName in failures[listName]) {
serials[listName][subName] = -1;
}
}
var loadedSubs = PolicyManager.getSubscriptionRulesets();
- for (var listName in loadedSubs) {
- for (var subName in loadedSubs[listName]) {
+ for (let listName in loadedSubs) {
+ for (let subName in loadedSubs[listName]) {
if (!serials[listName]) {
serials[listName] = {};
}
- var rawRuleset = loadedSubs[listName][subName].rawRuleset;
- serials[listName][subName] = rawRuleset._metadata['serial'];
+ let rawRuleset = loadedSubs[listName][subName].rawRuleset;
+ serials[listName][subName] = rawRuleset._metadata.serial;
}
}
function updateCompleted(result) {
@@ -284,30 +284,28 @@ var rpService = (function() {
self.observe = function(subject, topic, data) {
switch (topic) {
- case SUBSCRIPTION_UPDATED_TOPIC:
+ case SUBSCRIPTION_UPDATED_TOPIC: {
Logger.debug(Logger.TYPE_INTERNAL, 'XXX updated: ' + data);
// TODO: check if the subscription is enabled. The user might have
// disabled it between the time the update started and when it
// completed.
- var subInfo = JSON.parse(data);
- var failures = PolicyManager.loadSubscriptionRules(subInfo);
+ let subInfo = JSON.parse(data);
+ PolicyManager.loadSubscriptionRules(subInfo);
break;
+ }
- case SUBSCRIPTION_ADDED_TOPIC:
+ case SUBSCRIPTION_ADDED_TOPIC: {
Logger.debug(Logger.TYPE_INTERNAL, 'XXX added: ' + data);
- var subInfo = JSON.parse(data);
- var failures = PolicyManager.loadSubscriptionRules(subInfo);
- var failed = false;
- for (var listName in failures) {
- failed = true;
- }
+ let subInfo = JSON.parse(data);
+ let failures = PolicyManager.loadSubscriptionRules(subInfo);
+ let failed = Object.getOwnPropertyNames(failures).length > 0;
if (failed) {
- var serials = {};
- for (var listName in subInfo) {
+ let serials = {};
+ for (let listName in subInfo) {
if (!serials[listName]) {
serials[listName] = {};
}
- for (var subName in subInfo[listName]) {
+ for (let subName in subInfo[listName]) {
serials[listName][subName] = -1;
}
}
@@ -318,12 +316,14 @@ var rpService = (function() {
subscriptions.update(updateCompleted, serials);
}
break;
+ }
- case SUBSCRIPTION_REMOVED_TOPIC:
+ case SUBSCRIPTION_REMOVED_TOPIC: {
Logger.debug(Logger.TYPE_INTERNAL, 'YYY: ' + data);
- var subInfo = JSON.parse(data);
- var failures = PolicyManager.unloadSubscriptionRules(subInfo);
+ let subInfo = JSON.parse(data);
+ PolicyManager.unloadSubscriptionRules(subInfo);
break;
+ }
case "sessionstore-windows-restored":
showWelcomeWindow();
diff --git a/src/content/ui/menu.js b/src/content/ui/menu.js
index 6d006eb..cb285c8 100644
--- a/src/content/ui/menu.js
+++ b/src/content/ui/menu.js
@@ -240,12 +240,12 @@ window.rpcontinued.menu = (function () {
emptyList(list);
// check whether there are objects of GUILocation or just strings
- var guiLocations = values[0] && (values[0] instanceof GUILocation);
+ let guiLocations = values[0] && values[0] instanceof GUILocation;
if (true === guiLocations) {
// get prefs
- var sorting = rpPrefBranch.getCharPref('menu.sorting');
- var showNumRequests = rpPrefBranch.getBoolPref('menu.info.showNumRequests');
+ let sorting = rpPrefBranch.getCharPref('menu.sorting');
+ let showNumRequests = rpPrefBranch.getBoolPref('menu.info.showNumRequests');
if (sorting === "numRequests") {
values.sort(GUILocation.sortByNumRequestsCompareFunction);
@@ -253,9 +253,9 @@ window.rpcontinued.menu = (function () {
values.sort(GUILocation.compareFunction);
}
- for (var i in values) {
- var guiLocation = values[i];
- var props = guiLocation.properties;
+ for (let i in values) {
+ let guiLocation = values[i];
+ let props = guiLocation.properties;
let num;
if (true === showNumRequests) {
@@ -265,7 +265,7 @@ window.rpcontinued.menu = (function () {
"+" + props.numAllowedRequests + ")";
}
}
- var newitem = self._addListItem(list, 'rpc-od-item', guiLocation, num);
+ let newitem = self._addListItem(list, 'rpc-od-item', guiLocation, num);
newitem.setAttribute("default-policy",
props.numDefaultPolicyRequests > 0 ? "true" : "false");
@@ -274,7 +274,7 @@ window.rpcontinued.menu = (function () {
}
} else {
values.sort();
- for (var i in values) {
+ for (let i in values) {
self._addListItem(list, 'rpc-od-item', values[i]);
}
}
@@ -283,12 +283,12 @@ window.rpcontinued.menu = (function () {
self._populateOrigin = function() {
self._originDomainnameItem.setAttribute("value", self._currentBaseDomain);
- var showNumRequests = rpPrefBranch
+ let showNumRequests = rpPrefBranch
.getBoolPref('menu.info.showNumRequests');
- var props = self._getOriginGUILocationProperties();
+ let props = self._getOriginGUILocationProperties();
- var numRequests = '';
+ let numRequests = '';
if (true === showNumRequests) {
if (props.numAllowedRequests > 0 && props.numBlockedRequests > 0) {
numRequests = props.numRequests + " (" +
@@ -306,21 +306,21 @@ window.rpcontinued.menu = (function () {
};
self._populateOtherOrigins = function() {
- var guiOrigins = self._getOtherOriginsAsGUILocations();
+ let guiOrigins = self._getOtherOriginsAsGUILocations();
self._populateList(lists.otherOrigins, guiOrigins);
$id('rpc-other-origins').hidden = guiOrigins.length == 0;
};
self._populateDestinations = function(originIdentifier) {
- var destsWithBlockedRequests = self._getBlockedDestinationsAsGUILocations();
- var destsWithAllowedRequests = self._getAllowedDestinationsAsGUILocations();
+ let destsWithBlockedRequests = self._getBlockedDestinationsAsGUILocations();
+ let destsWithAllowedRequests = self._getAllowedDestinationsAsGUILocations();
- var destsWithSolelyBlockedRequests = [];
- var destsMixed = [];
- var destsWithSolelyAllowedRequests = [];
+ let destsWithSolelyBlockedRequests = [];
+ let destsMixed = [];
+ let destsWithSolelyAllowedRequests = [];
// Set operations would be nice. These are small arrays, so keep it simple.
- for (var i = 0; i < destsWithBlockedRequests.length; i++) {
+ for (let i = 0; i < destsWithBlockedRequests.length; i++) {
let blockedGUIDest = destsWithBlockedRequests[i];
if (false === GUILocation.existsInArray(blockedGUIDest,
@@ -330,12 +330,12 @@ window.rpcontinued.menu = (function () {
destsMixed.push(blockedGUIDest);
}
}
- for (var i = 0; i < destsWithAllowedRequests.length; i++) {
+ for (let i = 0; i < destsWithAllowedRequests.length; i++) {
let allowedGUIDest = destsWithAllowedRequests[i];
- var indexRawBlocked = GUIDestination.
+ let indexRawBlocked = GUIDestination.
indexOfDestInArray(allowedGUIDest, destsWithBlockedRequests);
- var destsMixedIndex = GUIDestination.
+ let destsMixedIndex = GUIDestination.
indexOfDestInArray(allowedGUIDest, destsMixed);
if (indexRawBlocked == -1) {
@@ -373,13 +373,13 @@ window.rpcontinued.menu = (function () {
};
self._populateDetails = function() {
- var origin = self._currentlySelectedOrigin;
- var dest = self._currentlySelectedDest;
+ let origin = self._currentlySelectedOrigin;
+ let dest = self._currentlySelectedDest;
emptyList(lists.removeRules);
emptyList(lists.addRules);
- var ruleData = {
+ let ruleData = {
'o' : {
'h' : self._addWildcard(origin)
}
@@ -517,16 +517,16 @@ window.rpcontinued.menu = (function () {
};
self._resetSelectedDest = function() {
- for (var i = 0; i < lists.blockedDestinations.childNodes.length; i++) {
- var child = lists.blockedDestinations.childNodes[i];
+ for (let i = 0; i < lists.blockedDestinations.childNodes.length; i++) {
+ let child = lists.blockedDestinations.childNodes[i];
child.setAttribute('selected-dest', 'false');
}
- for (var i = 0; i < lists.mixedDestinations.childNodes.length; i++) {
- var child = lists.mixedDestinations.childNodes[i];
+ for (let i = 0; i < lists.mixedDestinations.childNodes.length; i++) {
+ let child = lists.mixedDestinations.childNodes[i];
child.setAttribute('selected-dest', 'false');
}
- for (var i = 0; i < lists.allowedDestinations.childNodes.length; i++) {
- var child = lists.allowedDestinations.childNodes[i];
+ for (let i = 0; i < lists.allowedDestinations.childNodes.length; i++) {
+ let child = lists.allowedDestinations.childNodes[i];
child.setAttribute('selected-dest', 'false');
}
};
@@ -646,10 +646,10 @@ window.rpcontinued.menu = (function () {
};
self.processQueuedRuleChanges = function() {
- var rulesChanged = false;
- for (var ruleAction in self._ruleChangeQueues) {
- for (var canonicalRule in self._ruleChangeQueues[ruleAction]) {
- var ruleData = self._ruleChangeQueues[ruleAction][canonicalRule];
+ let rulesChanged = false;
+ for (let ruleAction in self._ruleChangeQueues) {
+ for (let canonicalRule in self._ruleChangeQueues[ruleAction]) {
+ let ruleData = self._ruleChangeQueues[ruleAction][canonicalRule];
self._processRuleChange(ruleAction, ruleData);
rulesChanged = true;
}
@@ -1017,14 +1017,14 @@ window.rpcontinued.menu = (function () {
// TODO: can we avoid calling getAllowedRequests here and reuse a result
// from calling it earlier?
- var reqSet = RequestProcessor.getAllowedRequests(
+ let reqSet = RequestProcessor.getAllowedRequests(
self._currentlySelectedOrigin, self._allRequestsOnDocument);
- var requests = reqSet.getAllMergedOrigins();
+ let requests = reqSet.getAllMergedOrigins();
//var rules = {};
- var userRules = {};
- var subscriptionRules = {};
+ let userRules = {};
+ let subscriptionRules = {};
//reqSet.print('allowedRequests');
@@ -1032,17 +1032,17 @@ window.rpcontinued.menu = (function () {
//var destBase = DomainUtil.getBaseDomain(
// self._currentlySelectedDest);
- for (var destBase in requests) {
+ for (let destBase in requests) {
if (self._currentlySelectedDest &&
self._currentlySelectedDest != destBase) {
continue;
}
- for (var destIdent in requests[destBase]) {
+ for (let destIdent in requests[destBase]) {
var destinations = requests[destBase][destIdent];
- for (var destUri in destinations) {
+ for (let destUri in destinations) {
// This will be null when the request was denied because of a default
// allow rule. However about any other time?
@@ -1059,11 +1059,10 @@ window.rpcontinued.menu = (function () {
// at the first RequestResult object, but at all. (there might be
// several requests with identical origin and destination URI.)
- for (var i in results.matchedAllowRules) {
+ for (let i in results.matchedAllowRules) {
- var ruleset, match;
- [ruleset, match] = results.matchedAllowRules[i];
- var rawRule = Ruleset.matchToRawRule(match);
+ let [ruleset, match] = results.matchedAllowRules[i];
+ let rawRule = Ruleset.matchToRawRule(match);
if (!self._currentlySelectedDest) {
if (rawRule.d && rawRule.d.h) {
@@ -1071,7 +1070,7 @@ window.rpcontinued.menu = (function () {
}
}
- var rawRuleStr = Ruleset.rawRuleToCanonicalString(rawRule);
+ let rawRuleStr = Ruleset.rawRuleToCanonicalString(rawRule);
//Logger.info(Logger.TYPE_POLICY,
// "matched allow rule: " + rawRuleStr);
// This is how we remove duplicates: if two rules have the same
@@ -1086,13 +1085,13 @@ window.rpcontinued.menu = (function () {
}
}
- for (var i in userRules) {
+ for (let i in userRules) {
self._addMenuItemRemoveAllowRule(list, userRules[i], false);
}
// TODO: for subscription rules, we need the effect of the menu item to be
// adding a deny rule instead of removing an allow rule. However, the text
// used for the item needs to be the same as removing an allow rule.
- for (var i in subscriptionRules) {
+ for (let i in subscriptionRules) {
self._addMenuItemRemoveAllowRule(list, subscriptionRules[i], true);
}
};
@@ -1101,14 +1100,14 @@ window.rpcontinued.menu = (function () {
// TODO: can we avoid calling getDeniedRequests here and reuse a result
// from calling it earlier?
- var reqSet = RequestProcessor.getDeniedRequests(
+ let reqSet = RequestProcessor.getDeniedRequests(
self._currentlySelectedOrigin, self._allRequestsOnDocument);
- var requests = reqSet.getAllMergedOrigins();
+ let requests = reqSet.getAllMergedOrigins();
//var rules = {};
- var userRules = {};
- var subscriptionRules = {};
+ let userRules = {};
+ let subscriptionRules = {};
reqSet.print('deniedRequests');
@@ -1116,17 +1115,17 @@ window.rpcontinued.menu = (function () {
//var destBase = DomainUtil.getBaseDomain(
// self._currentlySelectedDest);
- for (var destBase in requests) {
+ for (let destBase in requests) {
if (self._currentlySelectedDest &&
self._currentlySelectedDest != destBase) {
continue;
}
- for (var destIdent in requests[destBase]) {
+ for (let destIdent in requests[destBase]) {
- var destinations = requests[destBase][destIdent];
- for (var destUri in destinations) {
+ let destinations = requests[destBase][destIdent];
+ for (let destUri in destinations) {
// This will be null when the request was denied because of a default
// deny rule. However about any other time?
@@ -1137,15 +1136,14 @@ window.rpcontinued.menu = (function () {
continue;
}
- var results = destinations[destUri][0]; // TODO: Do not look only
+ let results = destinations[destUri][0]; // TODO: Do not look only
// at the first RequestResult object, but at all. (there may be
// several requests with identical origin and destination URI.)
- for (var i in results.matchedDenyRules) {
+ for (let i in results.matchedDenyRules) {
- var ruleset, match;
- [ruleset, match] = results.matchedDenyRules[i];
- var rawRule = Ruleset.matchToRawRule(match);
+ let [ruleset, match] = results.matchedDenyRules[i];
+ let rawRule = Ruleset.matchToRawRule(match);
if (!self._currentlySelectedDest) {
if (rawRule.d && rawRule.d.h) {
@@ -1153,7 +1151,7 @@ window.rpcontinued.menu = (function () {
}
}
- var rawRuleStr = Ruleset.rawRuleToCanonicalString(rawRule);
+ let rawRuleStr = Ruleset.rawRuleToCanonicalString(rawRule);
//Logger.info(Logger.TYPE_POLICY,
// "matched allow rule: " + rawRuleStr);
// This is how we remove duplicates: if two rules have the same
@@ -1168,37 +1166,37 @@ window.rpcontinued.menu = (function () {
}
}
- for (var i in userRules) {
+ for (let i in userRules) {
self._addMenuItemRemoveDenyRule(list, userRules[i], false);
}
// TODO: for subscription rules, we need the effect of the menu item to be
// adding an allow rule instead of removing a deny rule. However, the text
// used for the item needs to be the same as removing a deny rule.
- for (var i in subscriptionRules) {
+ for (let i in subscriptionRules) {
self._addMenuItemRemoveDenyRule(list, subscriptionRules[i], true);
}
};
self._populateDetailsAddSubdomainAllowRules = function(list) {
- var origin = self._currentlySelectedOrigin;
+ let origin = self._currentlySelectedOrigin;
// TODO: can we avoid calling getDeniedRequests here and reuse a result
// from calling it earlier?
- var reqSet = RequestProcessor.getDeniedRequests(
+ let reqSet = RequestProcessor.getDeniedRequests(
self._currentlySelectedOrigin, self._allRequestsOnDocument);
- var requests = reqSet.getAllMergedOrigins();
+ let requests = reqSet.getAllMergedOrigins();
- var destHosts = {};
+ let destHosts = {};
- for (var destBase in requests) {
+ for (let destBase in requests) {
if (self._currentlySelectedDest &&
self._currentlySelectedDest != destBase) {
continue;
}
- for (var destIdent in requests[destBase]) {
- var destinations = requests[destBase][destIdent];
- for (var destUri in destinations) {
+ for (let destIdent in requests[destBase]) {
+ let destinations = requests[destBase][destIdent];
+ for (let destUri in destinations) {
destHosts[DomainUtil.getHost(destUri)] = null;
}
}
@@ -1206,8 +1204,8 @@ window.rpcontinued.menu = (function () {
let mayPermRulesBeAdded = WindowUtils.mayPermanentRulesBeAdded(window);
- for (var destHost in destHosts) {
- var ruleData = {
+ for (let destHost in destHosts) {
+ let ruleData = {
'o' : {
'h' : self._addWildcard(origin)
},
@@ -1223,7 +1221,7 @@ window.rpcontinued.menu = (function () {
self._addMenuItemTempAllowOriginToDest(list, ruleData);
}
- var destOnlyRuleData = {
+ let destOnlyRuleData = {
'd' : {
'h': destHost
}
--
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