diff options
| -rw-r--r-- | chrome/content/code/redirect.js | 19 | ||||
| -rw-r--r-- | chrome/content/code/redirector.prototype.js | 4 | ||||
| -rw-r--r-- | chrome/content/unittest/testcases.js | 4 | 
3 files changed, 13 insertions, 14 deletions
diff --git a/chrome/content/code/redirect.js b/chrome/content/code/redirect.js index dcd3596..439dd92 100644 --- a/chrome/content/code/redirect.js +++ b/chrome/content/code/redirect.js @@ -1,7 +1,9 @@  //// $Id$
 -function Redirect(exampleUrl, includePattern, excludePattern, patternType, unescapeMatches, disabled) {
 -	this._init(exampleUrl, includePattern, excludePattern, patternType, unescapeMatches, disabled);
 +                exampleUrl,pattern,redirectUrl,patternType,excludePattern
 +
 +function Redirect(exampleUrl, includePattern, redirectUrl, patternType, excludePattern, unescapeMatches, disabled) {
 +	this._init(exampleUrl, includePattern, redirectUrl, patternType, excludePattern, unescapeMatches, disabled);
  }
  //Static
 @@ -68,7 +70,7 @@ Redirect.prototype = {  		return new RegExp(this._preparePattern(pattern),"gi");
  	},
 -	_init : function(exampleUrl, includePattern, excludePattern, redirectUrl, patternType, unescapeMatches, disabled) {
 +	_init : function(exampleUrl, includePattern, redirectUrl, patternType, excludePattern, unescapeMatches, disabled) {
  		this.exampleUrl = exampleUrl || '';
  		this.includePattern = includePattern || '';
  		this.excludePattern = excludePattern || '';
 @@ -101,24 +103,25 @@ Redirect.prototype = {  	test : function() {
  		return this.getMatch(this.exampleUrl);	
  	},
 +                exampleUrl,pattern,redirectUrl,patternType,excludePattern
  	serialize : function() {
  		return [ this.exampleUrl
  			   , this.includePattern
 -			   , this.excludePattern
  			   , this.redirectUrl
  			   , this.patternType
 +			   , this.excludePattern
  			   , this.unescapeMatches
  			   , this.disabled ].join(',,,');
  	},
  	deserialize : function(str) {
  		if (!str || !str.split) {
 -			//TODO: THROW ERROR	
 +			throw Error("Invalid serialized redirect: " + str);
  		}	
  		var parts = str.split(',,,');
  		if (parts.length < 5) {
 -			///TODO: throw
 +			throw Error("Invalid serialized redirect, too few fields: " + str);
  		}
  		this._init.apply(this, parts);
  	},
 @@ -172,8 +175,8 @@ Redirect.prototype = {      clone : function() {
  		return new Redirect(this.exampleUrl, this.includePattern, 
 -							this.excludePattern, this.redirectUrl, 
 -							this.patternType, this.unescapeMatches,
 +							this.redirectUrl, this.patternType, 
 +							this.excludePattern, this.unescapeMatches,
  							this.disabled);    
      },
 diff --git a/chrome/content/code/redirector.prototype.js b/chrome/content/code/redirector.prototype.js index a20a46a..9135e50 100644 --- a/chrome/content/code/redirector.prototype.js +++ b/chrome/content/code/redirector.prototype.js @@ -46,10 +46,6 @@ Redirector.prototype = {  	    }
      },
 -    observe : function(topic, subject, data) {
 -		dump("HEEEEEEEEEEEEEEEEEEEEE");    
 -    },
 -    
      loadStrings : function() {
          var src = 'chrome://redirector/locale/redirector.properties';
          var localeService = Cc["@mozilla.org/intl/nslocaleservice;1"].getService(Ci.nsILocaleService);
 diff --git a/chrome/content/unittest/testcases.js b/chrome/content/unittest/testcases.js index ece1a67..0ce071e 100644 --- a/chrome/content/unittest/testcases.js +++ b/chrome/content/unittest/testcases.js @@ -15,7 +15,7 @@ var tests = {  				}
  				redirectUrl = redirectUrl.substr(0, redirectUrl.length-1);
  			}
 -			var redirect = new Redirect(null, pattern, null, redirectUrl, Redirect.WILDCARD, null);
 +			var redirect = new Redirect(null, pattern, redirectUrl, Redirect.WILDCARD);
  			var result = redirect.getMatch(url);
  			return { passed: result.isMatch && (result.redirectTo == expected), message : "Expected '" + expected + "', actual was '" + result.redirectTo + "'"};
  		},
 @@ -53,7 +53,7 @@ var tests = {  				}
  				redirectUrl = redirectUrl.substr(0, redirectUrl.length-1);
  			}
 -			var redirect = new Redirect(null, pattern, null, redirectUrl, Redirect.REGEX, null);
 +			var redirect = new Redirect(null, pattern, redirectUrl, Redirect.REGEX, null, null);
  			var result = redirect.getMatch(url);
  			return { passed: result.isMatch && result.redirectTo == expected, message : "Expected '" + expected + "', actual was '" + result.redirectTo + "'"};
  		},
  | 
