=== removed file 'latest-changes.patch'
--- latest-changes.patch	2013-06-26 21:32:23 +0000
+++ latest-changes.patch	1970-01-01 00:00:00 +0000
@@ -1,508 +0,0 @@
-=== modified file 'lib/html_script_finder/dom_handler.js'
---- lib/html_script_finder/dom_handler.js	2013-06-26 19:23:43 +0000
-+++ lib/html_script_finder/dom_handler.js	2013-06-26 19:52:01 +0000
-@@ -496,7 +496,8 @@
-    *
-    */
-   removeAllJs: function (reason) {
--	  
-+    // remove all js is useless from now on.
-+
- 	  this.hasRemovedScripts = true;
- 	  
- 	  // removeAllJs needs not be run next time.
-
-=== modified file 'lib/html_script_finder/dom_handler/dom_checker.js'
---- lib/html_script_finder/dom_handler/dom_checker.js	2013-06-09 03:44:22 +0000
-+++ lib/html_script_finder/dom_handler/dom_checker.js	2013-06-26 21:21:57 +0000
-@@ -194,7 +194,7 @@
- 	  }
- 
-  	  // process the result.
-- 	  if (check === checkTypes.FREE) {
-+ 	  if (check === checkTypes.FREE) {
- 
- 	    // this is free.
-  	    this.d.inlineJsFree = true;
-@@ -203,30 +203,21 @@
- 
-  	  }
- 	  
--	  else if (check === checkTypes.FREE_NONTRIVIAL_GLOBAL) {
-+	  else if (check === checkTypes.FREE) {
- 
- 	    // the rest inline should be free.
- 	    this.d.inlineJsFree = true;
- 
--	    // trivial nonfree is disallowed.
--	    this.d.allowTrivial = false;
-+      // preventing trivial from running is deprecated.
-+	    // this.d.allowTrivial = false;
- 
- 	    // accept this script.
- 	    script.tagAsAccepted(this.d.pageURL, reasons.FREE);
- 	  }
- 	  
--	  else if (check === checkTypes.NONTRIVIAL_GLOBAL) {
--
--	    // trivial nonfree is disallowed.
--	    this.d.allowTrivial = false;
--
--	    if (!this.d.inlineJsFree) {
--		    // inline is not free. Remove.
--		    this.d.removeAllJs(reasons.CONSTRUCT);
--		    //return;
--	    } 
-+	  else if (check === checkTypes.NONTRIVIAL) {
- 	    
--	    else if (this.d.inlineJsFree) {
-+	    if (this.d.inlineJsFree) {
- 		    // inline is free. So accept.
- 		    script.tagAsAccepted(this.d.pageURL, reasons.FREE);
- 		    
-@@ -234,37 +225,24 @@
- 
- 	  }
- 	  
--	  if (this.d.allowTrivial === true &&
--	      check === checkTypes.TRIVIAL) {
-+	  if (check === checkTypes.TRIVIAL) {
- 	    // add entry as accepted.
--	    script.tagAsAccepted(this.d.pageURL, reasons.TRIVIAL);
-+	    script.tagAsAccepted(this.d.pageURL, check.reason);
- 	  } 
- 	  
- 	  else if (!this.d.inlineJsFree &&
- 		         this.d.loadsHtmlExternalScripts &&
--		         check === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
-+		         check === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
- 	    // nontrivial, because defines function and loads
- 	    // external scripts.
--	    this.d.removeAllJs(reasons.FUNCTIONS_INLINE);
-+	    this.d.removeGivenJs(script, reasons.FUNCTIONS_INLINE);
- 	  } 
- 	  else if (!this.d.loadsHtmlExternalScripts &&
--		         check === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
--	    
--	    script.tagAsAccepted(this.d.pageURL, reasons.TRIVIAL);
--	    
--	  }
--
--	  else if (!this.d.inlineJsFree &&
--		         this.d.allowTrivial.allowed === false &&
--		         (check === checkTypes.TRIVIAL ||
--		          check === checkTypes.TRIVIAL_DEFINES_FUNCTION)) {
--	    this.d.removeGivenJs(script, reasons.TRIVIAL_NOT_ALLOWED);
--	  }
--
--
--	  if (this.d.allowTrivial === false) {
--	    this.checkArrayForTrivial(false);
--	  } 
-+		         check === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
-+	    
-+	    script.tagAsAccepted(this.d.pageURL, reasons.TRIVIAL);
-+	    
-+	  }
- 	  
- 	  // next inline script, if applicable.
- 	  this.checkAllInlineScripts();
-@@ -346,14 +324,14 @@
-   },
- 
-   wrapUpBeforeLeaving: function () {
--	  
-+	  /*
- 	  if (this.d.allowTrivial === false ||
- 	      this.d.hasRemovedScripts) {
- 	    
- 	    this.checkArrayForTrivial(true);
- 
- 	  }
--
-+     */
- 	  //console.log('wrapping up');
- 	  this.d.callback(this.d.dom);
- 
-@@ -390,44 +368,24 @@
- 		    script.status = statusTypes.CHECKED;		
- 	    } 
- 	    
--
--	    if (check === checkTypes.FREE_NONTRIVIAL_GLOBAL) {
--	      
--	      // accept script. it's free!
--	      script.tagAsAccepted(this.d.pageURL, reasons.FREE);
--
--	      // set token to look at other scripts in retrospect to
--	      // forbid trivial scripts.
--	      this.d.allowTrivial = false;
--	    }
--
--
--	    else if (check === checkTypes.FREE) {
-+	    if (check === checkTypes.FREE) {
- 	      
- 	      // add entry as accepted.
- 	      script.tagAsAccepted(this.d.pageURL, reasons.FREE);
- 
- 	    } 
- 	    
--	    else if (check === checkTypes.NONTRIVIAL_GLOBAL) {
-+	    else if (check === checkTypes.NONTRIVIAL) {
- 
--	      this.d.removeGivenJs(script, reasons.CONSTRUCT);
-+	      this.d.removeGivenJs(script, check.reason);
- 	      this.d.allowTrivial = false;
- 	    }
- 	    
--	    else if (check === checkTypes.TRIVIAL) {
-+	    else if (check === checkTypes.TRIVIAL) {
- 	      
--	      if (this.d.allowTrivial === false) {
--
--		      // if trivial is forbidden, remove.
--		      this.d.removeGivenJs(script, reasons.TRIVIAL_NOT_ALLOWED);
--
--	      } else {
--
- 		      // if it's accepted, allow.
--		      script.tagAsAccepted(this.d.pageURL, reasons.TRIVIAL);
-+		      script.tagAsAccepted(this.d.pageURL, check.reason);
- 
--	      }
- 	    }
- 
- 	    else {
-@@ -487,8 +445,8 @@
- 
- 
- 
--		      if (this.d.scripts[i].result === checkTypes.TRIVIAL ||
--			        this.d.scripts[i].result === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
-+		      if (this.d.scripts[i].result.type === checkTypes.TRIVIAL ||
-+			        this.d.scripts[i].result.type === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
- 			      this.d.removeScriptIfDependent(this.d.scripts[i]);
- 			    }
- 
-@@ -496,7 +454,7 @@
- 		    if (checkAll) {
- 
- 			    if (type === scriptTypes.EXTERNAL &&
--			        this.d.scripts[i].result === checkTypes.TRIVIAL) {
-+			        this.d.scripts[i].result.type === checkTypes.TRIVIAL) {
- 			      
- 			      this.d.removeScriptIfDependent(this.d.scripts[i]);	
- 			    }
-
-=== modified file 'lib/html_script_finder/dom_handler/script_object.js'
---- lib/html_script_finder/dom_handler/script_object.js	2013-06-09 03:44:22 +0000
-+++ lib/html_script_finder/dom_handler/script_object.js	2013-06-26 21:24:41 +0000
-@@ -87,9 +87,9 @@
- 	  
- 	  this.element.setAttribute('data-librejs', 'accepted');
- 
--	  /*if (reason != undefined) {
-+//	  if (reason != undefined) {
- 	   this.element.setAttribute('data-librejs-reason', reason);
--	   }*/
-+	//  }
- 	  
- 	  acceptedScripts.addAScript(pageURL, {'inline': inline,
- 					                               'contents': content
-@@ -104,9 +104,9 @@
- 
- 	  this.element.setAttribute('data-librejs', 'rejected');
- 
--	  /*if (reason != undefined) {
-+	  //if (reason != undefined) {
- 	   this.element.setAttribute('data-librejs-reason', reason);
--	   }*/
-+	   //}
- 	  
- 	  removedScripts.addAScript(pageURL, {'inline': inline,
- 					                              'contents': content});
-
-=== modified file 'lib/http_observer/process_response.js'
---- lib/http_observer/process_response.js	2013-06-26 19:23:43 +0000
-+++ lib/http_observer/process_response.js	2013-06-26 19:39:40 +0000
-@@ -271,8 +271,7 @@
- 	    // for testing only.
- 	    // var jsCheckString = checkTypes.FREE;
-       
--	    if (jsCheckString === checkTypes.NONTRIVIAL_LOCAL ||
--		      jsCheckString === checkTypes.NONTRIVIAL_GLOBAL) {
-+	    if (jsCheckString === checkTypes.NONTRIVIAL) {
- 		    scriptObj = {inline: false,
- 			               contents: 'this script embedded dynamically was removed: '+ this.url,
- 			               removalReason: 'nontrivial'};
-@@ -285,7 +284,6 @@
- 		    this.jsListenerCallback();
- 
- 	    } else if (jsCheckString === checkTypes.FREE ||
--		             jsCheckString === checkTypes.FREE_NONTRIVIAL_GLOBAL ||
- 		             jsCheckString === checkTypes.TRIVIAL ||
- 		             jsCheckString === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
- 
-
-=== modified file 'lib/js_checker/constant_types.js'
---- lib/js_checker/constant_types.js	2013-06-26 19:23:43 +0000
-+++ lib/js_checker/constant_types.js	2013-06-26 20:42:57 +0000
-@@ -121,7 +121,7 @@
-   WITH: 98
- };
- 
--exports.checkTypes = {
-+var checkTypes = {
-   // trivial.
-   TRIVIAL: 1,
- 
-@@ -129,18 +129,16 @@
-   // be trivial in the end.
-   TRIVIAL_DEFINES_FUNCTION: 2,
- 
--  // might not be used as jsChecker level
--  // since TRIVIAL_DEFINES_FUNCTION does it.
--  // but can be used later on depending on the
--  // HTML parent.
--  NONTRIVIAL_LOCAL: 3,
--
--  // nontrivial construct.
--  NONTRIVIAL_GLOBAL: 4,
--
-+  NONTRIVIAL: 3,
-   // Free
--  FREE: 5,
--
--  // Free but disallowing trivial.
--  FREE_NONTRIVIAL_GLOBAL: 6
-+  FREE: 4
-+
-+};
-+
-+exports.checkTypes = checkTypes;
-+
-+exports.nontrivialComment = function (comment) {
-+  // ignore comment for now.
-+  return checkTypes.NONTRIVIAL;
-+         
- };
-\ No newline at end of file
-
-=== modified file 'lib/js_checker/js_checker.js'
---- lib/js_checker/js_checker.js	2013-06-09 03:44:22 +0000
-+++ lib/js_checker/js_checker.js	2013-06-26 21:14:03 +0000
-@@ -157,7 +157,9 @@
- 	    this.freeToken = false;
- 	    this.nontrivialness = false;
- 
--	    this.nonTrivialChecker = nonTrivialModule.nonTrivialChecker();
-+      // use this.hash to keep track of comments made by the nontrivial checker code
-+      // about why/how the code is found to be nontrivial.
-+	    this.nonTrivialChecker = nonTrivialModule.nonTrivialChecker(this.hash);
- 
- 	    // register callback and hash. So that result
- 	    // can be passed.
-@@ -171,7 +173,6 @@
- 	    this.handleTree(false);
- 	  }
- 	  
--
-   },
- 
-   handleTree: function (tree) {
-@@ -181,7 +182,7 @@
- 
- 	    // error parsing tree. Just return nonfree nontrivial global.
- 	    this.parseTree = {};
--	    this.parseTree.freeTrivialCheck = checkTypes.NONTRIVIAL_GLOBAL; 
-+	    this.parseTree.freeTrivialCheck = checkTypes.NONTRIVIAL; 
- 
- 	    // cache result with hash of script for future checks.
- 	    scriptsCached.addEntry(this.jsCode, this.parseTree.freeTrivialCheck,
-@@ -200,7 +201,6 @@
- 
- 		    this.walkTree(tree);
- 
--		    
- 
- 	    } catch (x) {
- 		    console.log(x, x.lineNumber, x.fileName);
-@@ -225,11 +225,11 @@
- 
- 	  // actual result stored here. hack since we used parseTree before.
- 	  this.parseTree.freeTrivialCheck = result;
--
-+    
- 	  // cache result with hash of script for future checks.
- 	  scriptsCached.addEntry(this.jsCode, this.parseTree.freeTrivialCheck,
- 			                     this.relationChecker);
--
-+    
- 	  this.resultReady();
- 	  
-   },
-@@ -361,22 +361,18 @@
- 
- 		    that.checkNode(n);
- 
--		    if (that.freeToken === checkTypes.FREE && 
--		        that.nontrivialness === checkTypes.NONTRIVIAL_GLOBAL) {
-+		    if (that.freeToken === checkTypes.FREE) {
- 		      // nothing more to look for. We are done.
--		      that.walkTreeComplete(checkTypes.FREE_NONTRIVIAL_GLOBAL);
-+		      that.walkTreeComplete(checkTypes.FREE);
- 		      return;
- 		    } 
--		    
--		    else if (that.nontrivialness === checkTypes.NONTRIVIAL_GLOBAL) {
--		      // we already know there's no free license at the top,
--		      // and this is nontrivial global nothing more to look
--		      // for. We are done.
--		      that.walkTreeComplete(checkTypes.NONTRIVIAL_GLOBAL);
-+		    else if (that.nontrivialness === checkTypes.NONTRIVIAL) {
-+          // nontrivial
-+          // we are done.
-+          that.walkTreeComplete(checkTypes.NONTRIVIAL_GLOBAL);
- 		      return;
--		    }
--
--		    // call processQueue again if needed.
-+        }
-+	      // call processQueue again if needed.
- 		    end = Date.now();
- 
- 		    if (queue.length) {
-@@ -461,8 +457,8 @@
- 
- 	  
- 	  // if all code was fully analyzed.
--	  if (this.nontrivialness === checkTypes.NONTRIVIAL_GLOBAL) {
--	    this.getCheckerResult(checkTypes.NONTRIVIAL_GLOBAL);
-+	  if (this.nontrivialness === checkTypes.NONTRIVIAL) {
-+	    this.getCheckerResult(checkTypes.NONTRIVIAL);
- 	  }
- 	  
- 
-@@ -514,19 +510,17 @@
- 	    this.freeToken = checkTypes.FREE;
- 	  }
- 
--	  if (tc) {
-+	  if (tc) {
- 	    
--	    if (tc === checkTypes.NONTRIVIAL_GLOBAL) {
-+	    if (tc === checkTypes.NONTRIVIAL) {
- 
--		    // this is free and a construct that makes all scripts
--		    // globally nontrivial.
--		    this.nontrivialness = checkTypes.NONTRIVIAL_GLOBAL;
-+        // nontrivial_global is deprecated
-+		    this.nontrivialness = checkTypes.NONTRIVIAL;
- 		    return;
- 	    }
- 
--  	  else if (tc === checkTypes.TRIVIAL_DEFINES_FUNCTION &&
--		           this.nontrivialness != checkTypes.NONTRIVIAL_GLOBAL) {
--		    this.nontrivialness =  checkTypes.TRIVIAL_DEFINES_FUNCTION;
-+  	  else if (tc === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
-+		    this.nontrivialness = checkTypes.TRIVIAL_DEFINES_FUNCTION;
- 		    return;
- 	    }
- 
-
-=== modified file 'lib/js_checker/nontrivial_checker.js'
---- lib/js_checker/nontrivial_checker.js	2013-06-26 19:23:43 +0000
-+++ lib/js_checker/nontrivial_checker.js	2013-06-26 20:46:02 +0000
-@@ -25,6 +25,7 @@
- const token = types.token;
- 
- var checkTypes = types.checkTypes;
-+var ntComment = types.nontrivialComment;
- 
- var utils = {
- 
-@@ -100,7 +101,7 @@
- var nonTrivialChecker = { 
- 
-   definesFunction: false,
--  
-+  hash: null,
-   /**
-    * definesFunctionFound
-    *
-@@ -325,63 +326,53 @@
-   checkNontrivial: function (n, t) {
- 
- 	  if (n.type === token.IDENTIFIER && this.evalIdentifier(n)) {
--	    //console.log("NONTRIVIAL: eval has been found in code");
--	    return checkTypes.NONTRIVIAL_GLOBAL;
-+      return ntComment("NONTRIVIAL: eval has been found in code");
- 	  }
- 
- 	  if (this.innerHTMLIdentifier(n)) {
--	    //console.log("NONTRIVIAL: innerHTML identifier");
--	    return checkTypes.NONTRIVIAL_GLOBAL;
-+      return ntComment("NONTRIVIAL: innerHTML identifier");
- 	  }
- 	  
- 	  // the node is an identifier
- 	  if (n.type === token.IDENTIFIER && this.createsXhrObject(n)) {
--	    //console.log('NONTRIVIAL: Creates an xhr object');
--	    return checkTypes.NONTRIVIAL_GLOBAL;
-+      return ntComment('NONTRIVIAL: Creates an xhr object');
- 	  }
- 
- 	  // this is a method/function call
- 	  if (n.type === token.CALL) {
- 
- 	    if (this.invokesEval(n)) {
--		    //console.log("NONTRIVIAL: eval has been found in code");
--		    return checkTypes.NONTRIVIAL_GLOBAL;
-+        return ntComment("NONTRIVIAL: eval has been found in code");
- 	    }
- 
- 	    if (this.invokesMethodBracketSuffix(n)) {
--		    //console.log('NONTRIVIAL: square bracket suffix method call detected');
--		    return checkTypes.NONTRIVIAL_GLOBAL;
-+		    return ntComment('NONTRIVIAL: square bracket suffix method call detected');
- 	    }
- 
- 	    if (this.invokesXhrOpen(n)) {
--		    //console.log('NONTRIVIAL: an open method similar to xhr.open is used');
--		    return checkTypes.NONTRIVIAL_GLOBAL;
-+		    return ntComment('NONTRIVIAL: an open method similar to xhr.open is used');
- 	    }
- 
- 	    if (this.createsScriptElement(n)) {
--		    //console.log('NONTRIVIAL: creates script element dynamically.');
--		    return checkTypes.NONTRIVIAL_GLOBAL;
-+		    return ntComment('NONTRIVIAL: creates script element dynamically.');
- 	    }
- 
- 	    if (this.writesScriptAsHtmlString(n)) {
--		    //console.log('NONTRIVIAL: writes script as html dynamically.');
--		    return checkTypes.NONTRIVIAL_GLOBAL;
-+		    return ntComment('NONTRIVIAL: writes script as html dynamically.');
- 	    }
- 	  }
- 
- 	  // The node is a function definition. 
- 	  // Most common occurence.
- 	  if (this.definesFunctionFound(n)) {
--	    return checkTypes.TRIVIAL_DEFINES_FUNCTION;
-+	    return checkTypes.TRIVIAL_DEFINES_FUNCTION;
- 	  }
- 
- 	  // found nothing else, so trivial.
--	  return checkTypes.TRIVIAL;
-+	  return checkTypes.TRIVIAL;
-   }
- };
- 
- exports.nonTrivialChecker = function () {
--
-   var checker = Object.create(nonTrivialChecker);
--  
-   return checker;
- };
\ No newline at end of file

=== modified file 'lib/html_script_finder/dom_handler.js'
--- lib/html_script_finder/dom_handler.js	2013-06-26 21:40:55 +0000
+++ lib/html_script_finder/dom_handler.js	2013-06-26 21:43:58 +0000
@@ -496,8 +496,7 @@
    *
    */
   removeAllJs: function (reason) {
-    // remove all js is useless from now on.
-
+	  
 	  this.hasRemovedScripts = true;
 	  
 	  // removeAllJs needs not be run next time.

=== modified file 'lib/html_script_finder/dom_handler/dom_checker.js'
--- lib/html_script_finder/dom_handler/dom_checker.js	2013-06-26 21:40:55 +0000
+++ lib/html_script_finder/dom_handler/dom_checker.js	2013-06-26 21:43:58 +0000
@@ -203,21 +203,30 @@
 
  	  }
 	  
-	  else if (check === checkTypes.FREE) {
+	  else if (check === checkTypes.FREE_NONTRIVIAL_GLOBAL) {
 
 	    // the rest inline should be free.
 	    this.d.inlineJsFree = true;
 
-      // preventing trivial from running is deprecated.
-	    // this.d.allowTrivial = false;
+	    // trivial nonfree is disallowed.
+	    this.d.allowTrivial = false;
 
 	    // accept this script.
 	    script.tagAsAccepted(this.d.pageURL, reasons.FREE);
 	  }
 	  
-	  else if (check === checkTypes.NONTRIVIAL) {
+	  else if (check === checkTypes.NONTRIVIAL_GLOBAL) {
+
+	    // trivial nonfree is disallowed.
+	    this.d.allowTrivial = false;
+
+	    if (!this.d.inlineJsFree) {
+		    // inline is not free. Remove.
+		    this.d.removeAllJs(reasons.CONSTRUCT);
+		    //return;
+	    } 
 	    
-	    if (this.d.inlineJsFree) {
+	    else if (this.d.inlineJsFree) {
 		    // inline is free. So accept.
 		    script.tagAsAccepted(this.d.pageURL, reasons.FREE);
 		    
@@ -225,9 +234,10 @@
 
 	  }
 	  
-	  if (check === checkTypes.TRIVIAL) {
+	  if (this.d.allowTrivial === true &&
+	      check === checkTypes.TRIVIAL) {
 	    // add entry as accepted.
-	    script.tagAsAccepted(this.d.pageURL, check.reason);
+	    script.tagAsAccepted(this.d.pageURL, reasons.TRIVIAL);
 	  } 
 	  
 	  else if (!this.d.inlineJsFree &&
@@ -235,7 +245,7 @@
 		         check === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
 	    // nontrivial, because defines function and loads
 	    // external scripts.
-	    this.d.removeGivenJs(script, reasons.FUNCTIONS_INLINE);
+	    this.d.removeAllJs(reasons.FUNCTIONS_INLINE);
 	  } 
 	  else if (!this.d.loadsHtmlExternalScripts &&
 		         check === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
@@ -243,6 +253,18 @@
 	    script.tagAsAccepted(this.d.pageURL, reasons.TRIVIAL);
 	    
 	  }
+
+	  else if (!this.d.inlineJsFree &&
+		         this.d.allowTrivial.allowed === false &&
+		         (check === checkTypes.TRIVIAL ||
+		          check === checkTypes.TRIVIAL_DEFINES_FUNCTION)) {
+	    this.d.removeGivenJs(script, reasons.TRIVIAL_NOT_ALLOWED);
+	  }
+
+
+	  if (this.d.allowTrivial === false) {
+	    this.checkArrayForTrivial(false);
+	  } 
 	  
 	  // next inline script, if applicable.
 	  this.checkAllInlineScripts();
@@ -324,14 +346,14 @@
   },
 
   wrapUpBeforeLeaving: function () {
-	  /*
+	  
 	  if (this.d.allowTrivial === false ||
 	      this.d.hasRemovedScripts) {
 	    
 	    this.checkArrayForTrivial(true);
 
 	  }
-     */
+
 	  //console.log('wrapping up');
 	  this.d.callback(this.d.dom);
 
@@ -368,24 +390,44 @@
 		    script.status = statusTypes.CHECKED;		
 	    } 
 	    
-	    if (check === checkTypes.FREE) {
+
+	    if (check === checkTypes.FREE_NONTRIVIAL_GLOBAL) {
+	      
+	      // accept script. it's free!
+	      script.tagAsAccepted(this.d.pageURL, reasons.FREE);
+
+	      // set token to look at other scripts in retrospect to
+	      // forbid trivial scripts.
+	      this.d.allowTrivial = false;
+	    }
+
+
+	    else if (check === checkTypes.FREE) {
 	      
 	      // add entry as accepted.
 	      script.tagAsAccepted(this.d.pageURL, reasons.FREE);
 
 	    } 
 	    
-	    else if (check === checkTypes.NONTRIVIAL) {
+	    else if (check === checkTypes.NONTRIVIAL_GLOBAL) {
 
-	      this.d.removeGivenJs(script, check.reason);
+	      this.d.removeGivenJs(script, reasons.CONSTRUCT);
 	      this.d.allowTrivial = false;
 	    }
 	    
 	    else if (check === checkTypes.TRIVIAL) {
 	      
+	      if (this.d.allowTrivial === false) {
+
+		      // if trivial is forbidden, remove.
+		      this.d.removeGivenJs(script, reasons.TRIVIAL_NOT_ALLOWED);
+
+	      } else {
+
 		      // if it's accepted, allow.
-		      script.tagAsAccepted(this.d.pageURL, check.reason);
+		      script.tagAsAccepted(this.d.pageURL, reasons.TRIVIAL);
 
+	      }
 	    }
 
 	    else {
@@ -445,8 +487,8 @@
 
 
 
-		      if (this.d.scripts[i].result.type === checkTypes.TRIVIAL ||
-			        this.d.scripts[i].result.type === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
+		      if (this.d.scripts[i].result === checkTypes.TRIVIAL ||
+			        this.d.scripts[i].result === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
 			      this.d.removeScriptIfDependent(this.d.scripts[i]);
 			    }
 
@@ -454,7 +496,7 @@
 		    if (checkAll) {
 
 			    if (type === scriptTypes.EXTERNAL &&
-			        this.d.scripts[i].result.type === checkTypes.TRIVIAL) {
+			        this.d.scripts[i].result === checkTypes.TRIVIAL) {
 			      
 			      this.d.removeScriptIfDependent(this.d.scripts[i]);	
 			    }

=== modified file 'lib/html_script_finder/dom_handler/script_object.js'
--- lib/html_script_finder/dom_handler/script_object.js	2013-06-26 21:40:55 +0000
+++ lib/html_script_finder/dom_handler/script_object.js	2013-06-26 21:43:58 +0000
@@ -87,9 +87,9 @@
 	  
 	  this.element.setAttribute('data-librejs', 'accepted');
 
-//	  if (reason != undefined) {
+	  /*if (reason != undefined) {
 	   this.element.setAttribute('data-librejs-reason', reason);
-	//  }
+	   }*/
 	  
 	  acceptedScripts.addAScript(pageURL, {'inline': inline,
 					                               'contents': content
@@ -104,9 +104,9 @@
 
 	  this.element.setAttribute('data-librejs', 'rejected');
 
-	  //if (reason != undefined) {
+	  /*if (reason != undefined) {
 	   this.element.setAttribute('data-librejs-reason', reason);
-	   //}
+	   }*/
 	  
 	  removedScripts.addAScript(pageURL, {'inline': inline,
 					                              'contents': content});

=== modified file 'lib/http_observer/process_response.js'
--- lib/http_observer/process_response.js	2013-06-26 21:40:55 +0000
+++ lib/http_observer/process_response.js	2013-06-26 21:43:58 +0000
@@ -271,7 +271,8 @@
 	    // for testing only.
 	    // var jsCheckString = checkTypes.FREE;
       
-	    if (jsCheckString === checkTypes.NONTRIVIAL) {
+	    if (jsCheckString === checkTypes.NONTRIVIAL_LOCAL ||
+		      jsCheckString === checkTypes.NONTRIVIAL_GLOBAL) {
 		    scriptObj = {inline: false,
 			               contents: 'this script embedded dynamically was removed: '+ this.url,
 			               removalReason: 'nontrivial'};
@@ -284,6 +285,7 @@
 		    this.jsListenerCallback();
 
 	    } else if (jsCheckString === checkTypes.FREE ||
+		             jsCheckString === checkTypes.FREE_NONTRIVIAL_GLOBAL ||
 		             jsCheckString === checkTypes.TRIVIAL ||
 		             jsCheckString === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
 

=== modified file 'lib/js_checker/constant_types.js'
--- lib/js_checker/constant_types.js	2013-06-26 21:40:55 +0000
+++ lib/js_checker/constant_types.js	2013-06-26 21:43:58 +0000
@@ -121,7 +121,7 @@
   WITH: 98
 };
 
-var checkTypes = {
+exports.checkTypes = {
   // trivial.
   TRIVIAL: 1,
 
@@ -129,16 +129,18 @@
   // be trivial in the end.
   TRIVIAL_DEFINES_FUNCTION: 2,
 
-  NONTRIVIAL: 3,
+  // might not be used as jsChecker level
+  // since TRIVIAL_DEFINES_FUNCTION does it.
+  // but can be used later on depending on the
+  // HTML parent.
+  NONTRIVIAL_LOCAL: 3,
+
+  // nontrivial construct.
+  NONTRIVIAL_GLOBAL: 4,
+
   // Free
-  FREE: 4
-
-};
-
-exports.checkTypes = checkTypes;
-
-exports.nontrivialComment = function (comment) {
-  // ignore comment for now.
-  return checkTypes.NONTRIVIAL;
-         
+  FREE: 5,
+
+  // Free but disallowing trivial.
+  FREE_NONTRIVIAL_GLOBAL: 6
 };
\ No newline at end of file

=== modified file 'lib/js_checker/js_checker.js'
--- lib/js_checker/js_checker.js	2013-06-26 21:40:55 +0000
+++ lib/js_checker/js_checker.js	2013-06-26 21:43:58 +0000
@@ -157,9 +157,7 @@
 	    this.freeToken = false;
 	    this.nontrivialness = false;
 
-      // use this.hash to keep track of comments made by the nontrivial checker code
-      // about why/how the code is found to be nontrivial.
-	    this.nonTrivialChecker = nonTrivialModule.nonTrivialChecker(this.hash);
+	    this.nonTrivialChecker = nonTrivialModule.nonTrivialChecker();
 
 	    // register callback and hash. So that result
 	    // can be passed.
@@ -173,6 +171,7 @@
 	    this.handleTree(false);
 	  }
 	  
+
   },
 
   handleTree: function (tree) {
@@ -182,7 +181,7 @@
 
 	    // error parsing tree. Just return nonfree nontrivial global.
 	    this.parseTree = {};
-	    this.parseTree.freeTrivialCheck = checkTypes.NONTRIVIAL; 
+	    this.parseTree.freeTrivialCheck = checkTypes.NONTRIVIAL_GLOBAL; 
 
 	    // cache result with hash of script for future checks.
 	    scriptsCached.addEntry(this.jsCode, this.parseTree.freeTrivialCheck,
@@ -201,6 +200,7 @@
 
 		    this.walkTree(tree);
 
+		    
 
 	    } catch (x) {
 		    console.log(x, x.lineNumber, x.fileName);
@@ -225,11 +225,11 @@
 
 	  // actual result stored here. hack since we used parseTree before.
 	  this.parseTree.freeTrivialCheck = result;
-    
+
 	  // cache result with hash of script for future checks.
 	  scriptsCached.addEntry(this.jsCode, this.parseTree.freeTrivialCheck,
 			                     this.relationChecker);
-    
+
 	  this.resultReady();
 	  
   },
@@ -361,18 +361,22 @@
 
 		    that.checkNode(n);
 
-		    if (that.freeToken === checkTypes.FREE) {
+		    if (that.freeToken === checkTypes.FREE && 
+		        that.nontrivialness === checkTypes.NONTRIVIAL_GLOBAL) {
 		      // nothing more to look for. We are done.
-		      that.walkTreeComplete(checkTypes.FREE);
+		      that.walkTreeComplete(checkTypes.FREE_NONTRIVIAL_GLOBAL);
 		      return;
 		    } 
-		    else if (that.nontrivialness === checkTypes.NONTRIVIAL) {
-          // nontrivial
-          // we are done.
-          that.walkTreeComplete(checkTypes.NONTRIVIAL_GLOBAL);
+		    
+		    else if (that.nontrivialness === checkTypes.NONTRIVIAL_GLOBAL) {
+		      // we already know there's no free license at the top,
+		      // and this is nontrivial global nothing more to look
+		      // for. We are done.
+		      that.walkTreeComplete(checkTypes.NONTRIVIAL_GLOBAL);
 		      return;
-        }
-	      // call processQueue again if needed.
+		    }
+
+		    // call processQueue again if needed.
 		    end = Date.now();
 
 		    if (queue.length) {
@@ -457,8 +461,8 @@
 
 	  
 	  // if all code was fully analyzed.
-	  if (this.nontrivialness === checkTypes.NONTRIVIAL) {
-	    this.getCheckerResult(checkTypes.NONTRIVIAL);
+	  if (this.nontrivialness === checkTypes.NONTRIVIAL_GLOBAL) {
+	    this.getCheckerResult(checkTypes.NONTRIVIAL_GLOBAL);
 	  }
 	  
 
@@ -512,15 +516,17 @@
 
 	  if (tc) {
 	    
-	    if (tc === checkTypes.NONTRIVIAL) {
+	    if (tc === checkTypes.NONTRIVIAL_GLOBAL) {
 
-        // nontrivial_global is deprecated
-		    this.nontrivialness = checkTypes.NONTRIVIAL;
+		    // this is free and a construct that makes all scripts
+		    // globally nontrivial.
+		    this.nontrivialness = checkTypes.NONTRIVIAL_GLOBAL;
 		    return;
 	    }
 
-  	  else if (tc === checkTypes.TRIVIAL_DEFINES_FUNCTION) {
-		    this.nontrivialness = checkTypes.TRIVIAL_DEFINES_FUNCTION;
+  	  else if (tc === checkTypes.TRIVIAL_DEFINES_FUNCTION &&
+		           this.nontrivialness != checkTypes.NONTRIVIAL_GLOBAL) {
+		    this.nontrivialness =  checkTypes.TRIVIAL_DEFINES_FUNCTION;
 		    return;
 	    }
 

=== modified file 'lib/js_checker/nontrivial_checker.js'
--- lib/js_checker/nontrivial_checker.js	2013-06-26 21:40:55 +0000
+++ lib/js_checker/nontrivial_checker.js	2013-06-26 21:43:58 +0000
@@ -25,7 +25,6 @@
 const token = types.token;
 
 var checkTypes = types.checkTypes;
-var ntComment = types.nontrivialComment;
 
 var utils = {
 
@@ -101,7 +100,7 @@
 var nonTrivialChecker = { 
 
   definesFunction: false,
-  hash: null,
+  
   /**
    * definesFunctionFound
    *

