aboutsummaryrefslogtreecommitdiffstats
path: root/lib/js_checker/js_checker.js
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-01-09 22:58:04 -0500
committerJesús <heckyel@hyperbola.info>2021-01-09 22:58:04 -0500
commit62f96f35d471f7d0321636e78d5ae194eea6aae7 (patch)
treea13f865028fa2d5c11fc3c8bc9e67501f87dbef8 /lib/js_checker/js_checker.js
parent20aebe3faab7f064b4fdfdfe2f9a8c920f7d5fb2 (diff)
downloadlibrejsxul-62f96f35d471f7d0321636e78d5ae194eea6aae7.tar.lz
librejsxul-62f96f35d471f7d0321636e78d5ae194eea6aae7.tar.xz
librejsxul-62f96f35d471f7d0321636e78d5ae194eea6aae7.zip
version 6.0.14
Rebrand of LibreJS under Unified XUL Platform
Diffstat (limited to 'lib/js_checker/js_checker.js')
-rw-r--r--lib/js_checker/js_checker.js72
1 files changed, 36 insertions, 36 deletions
diff --git a/lib/js_checker/js_checker.js b/lib/js_checker/js_checker.js
index ecf0826..1d1fed9 100644
--- a/lib/js_checker/js_checker.js
+++ b/lib/js_checker/js_checker.js
@@ -1,24 +1,24 @@
/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
+ * GNU LibreJSXUL - A browser add-on to block nonfree nontrivial JavaScript.
* *
* Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
* Copyright (C) 2014, 2015 Nik Nyby
* Copyright (C) 2015 Ruben Rodriguez
*
- * This file is part of GNU LibreJS.
+ * This file is part of GNU LibreJSXUL.
*
- * GNU LibreJS is free software: you can redistribute it and/or modify
+ * GNU LibreJSXUL is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * GNU LibreJS is distributed in the hope that it will be useful,
+ * GNU LibreJSXUL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
+ * along with GNU LibreJSXUL. If not, see <http://www.gnu.org/licenses/>.
*/
var {Cc, Ci, Cu, Cm, Cr} = require("chrome");
@@ -45,23 +45,23 @@ const timer = require("sdk/timers");
var callbackMap = {};
/**
- *
- * Pairs a hash with a given callback
+ *
+ * Pairs a hash with a given callback
* method from an object.
- *
+ *
*/
var setHashCallback = function(hash, callback, notification) {
console.debug('setHashCallback', hash);
if (hash in callbackMap && isDryRun()) {
// workaround for issue with dryrun after checking box.
// do nothing.
- callbackMap[hash] = callback;
+ callbackMap[hash] = callback;
} else if (hash in callbackMap) {
console.debug("callback", callbackMap[hash]);
if (notification && typeof notification.close === 'function') {
notification.close();
}
- throw Error("already being checked.");
+ throw Error("already being checked.");
} else {
console.debug('setting callbackMap for', hash, 'to', callback);
callbackMap[hash] = callback;
@@ -78,7 +78,7 @@ var removeHashCallback = function(hash) {
/**
* find callback and return result (parse tree).
- *
+ *
*/
exports.callbackHashResult = function(hash, result) {
console.debug('typeof callbackMap function:', typeof callbackMap[hash]);
@@ -167,7 +167,7 @@ JsChecker.prototype.isFreeLicensed = function(script) {
JsChecker.prototype.searchJs = function(jsCode, resultReady, url) {
var that = this;
var bugfix = require('../html_script_finder/bug_fix')
- .narcissusBugFixLibreJS;
+ .narcissusBugFixLibreJSXUL;
console.debug('JsChecker.searchJs for script url:', url);
this.url = url;
this.resultReady = resultReady;
@@ -177,7 +177,7 @@ JsChecker.prototype.searchJs = function(jsCode, resultReady, url) {
.createNotification(this.shortText).notification;
var verbatimCode = this.jsCode.replace(bugfix, '');
- this.hash = scriptsCached.getHash(verbatimCode);
+ this.hash = scriptsCached.getHash(verbatimCode);
var isCached = scriptsCached.isCached(verbatimCode, this.hash);
if (isCached) {
console.debug("We have it cached indeed!");
@@ -254,14 +254,14 @@ JsChecker.prototype.handleTree = function(tree, errorMessage) {
/**
* getCheckerResult
- *
+ *
* Callback to Assign result from walkTree to property.
* reset parse tree. create cache entry.
- *
+ *
*/
JsChecker.prototype.getCheckerResult = function(result) {
// done with parse tree. Get rid of it.
- this.parseTree = {};
+ this.parseTree = {};
this.removeNotification();
this.parseTree.nonTrivialChecker = this.nonTrivialChecker;
@@ -279,13 +279,13 @@ JsChecker.prototype.getCheckerResult = function(result) {
/**
* trivialCheck
*
- * Runs nodes through a series of conditional statements
+ * Runs nodes through a series of conditional statements
* to find out whether it is trivial or not.
*
* @param {object} n. The current node being studied.
- * @param {string} t. The type of node being studied
+ * @param {string} t. The type of node being studied
* (initializer, functionbody, try block, ...)
- *
+ *
*/
JsChecker.prototype.trivialCheck = function(n) {
return this.nonTrivialChecker.checkNontrivial(n);
@@ -294,12 +294,12 @@ JsChecker.prototype.trivialCheck = function(n) {
/**
* freeCheck
*
- * Check if comments above current node could be a free licence.
+ * Check if comments above current node could be a free licence.
* If it is, then the script will be flagged as free.
*
* @param {object} n. The current node being studied.
* (initializer, functionbody, try block, ...)
- *
+ *
*/
JsChecker.prototype.freeCheck = function(n, ntype) {
var check = freeChecker.freeCheck.checkNodeFreeLicense(n, this.queue);
@@ -308,8 +308,8 @@ JsChecker.prototype.freeCheck = function(n, ntype) {
/**
* walkTree
- *
- * An iterative functionwalking the parse tree generated by
+ *
+ * An iterative functionwalking the parse tree generated by
* Narcissus.
*
* @param {object} node. The original node.
@@ -317,10 +317,10 @@ JsChecker.prototype.freeCheck = function(n, ntype) {
*/
JsChecker.prototype.walkTree = function(node) {
var queue = [node];
- var i,
+ var i,
len,
- n, counter = 0,
- result,
+ n, counter = 0,
+ result,
processQueue,
that = this;
@@ -352,7 +352,7 @@ JsChecker.prototype.walkTree = function(node) {
// fetch all the children.
len = n.children.length;
for (i = 0; i < len; i++) {
- if (n.children[i] != undefined &&
+ if (n.children[i] != undefined &&
n.children[i].visited == undefined
) {
// figure out siblings.
@@ -374,11 +374,11 @@ JsChecker.prototype.walkTree = function(node) {
if (n.type != undefined) {
// fetch all properties that may have nodes.
for (var item in n) {
- if (item != 'tokenizer' &&
+ if (item != 'tokenizer' &&
item != 'children' &&
- item != 'length' &&
- n[item] != null &&
- typeof n[item] === 'object' &&
+ item != 'length' &&
+ n[item] != null &&
+ typeof n[item] === 'object' &&
n[item].type != undefined &&
n[item].visited == undefined
) {
@@ -413,7 +413,7 @@ JsChecker.prototype.walkTree = function(node) {
if ((end - start) > 30) {
// been running more than 20ms, pause
- // for 10 ms before calling processQueue
+ // for 10 ms before calling processQueue
// again.
timer.setTimeout(processQueue, 8);
return;
@@ -451,10 +451,10 @@ JsChecker.prototype.cancelWalkTree = function() {
/**
* walkTreeComplete
- *
+ *
* Trigger when the walkTree has been completed or
* when it has been cut short.
- *
+ *
*/
JsChecker.prototype.walkTreeComplete = function(result) {
var that = this;
@@ -499,9 +499,9 @@ JsChecker.prototype.walkTreeComplete = function(result) {
/**
* checkNode
- *
+ *
* checks a single node.
- *
+ *
*/
JsChecker.prototype.checkNode = function(n) {
var sub;