[Pkg-mozext-commits] [SCM] perspectives-extension branch, debian, updated. 4.2-4-136-gd6962eb

Dave Schaefer dave.schaefer at gmail.com
Thu Jun 28 22:05:18 UTC 2012


The following commit has been merged in the debian branch:
commit 75884c9e1a0efef0804ebdf1796ef12adee5377e
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date:   Tue Jun 19 01:10:03 2012 -0700

    Perspectives - Fix hidden bug with uninitialized variables so things actually work in SeaMonkey.
    
    It looks like Firefox initializes the variables 'Cc' and 'Ci' by default to be references to Components.classes and Components.interfaces. But SeaMonkey does not!
    In SeaMonkey those variables are undefined. Thus any SeaMonkey client running this code would hit an exception and not return any notary results, ever.
    Fix that.
    
    Also document the purpose of prompt_update while we're at it (it had an offending Cc reference).

diff --git a/plugin/chrome/content/notaries.js b/plugin/chrome/content/notaries.js
index 5febb53..88caad8 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -324,7 +324,11 @@ var Perspectives = {
 	
 		if (req.readyState == 4) {  
 			if(req.status == 200){
-				try { 							
+				try {
+
+					//NOTE: Firefox pre-defines Cc and Ci, but SeaMonkey does not.
+					//We create local variables here so SeaMonkey clients don't throw 'variable not defined' exceptions
+					const Cc = Components.classes, Ci = Components.interfaces;
  
 					Pers_debug.d_print("query", req.responseText); 
 					var server_node = req.responseXML.documentElement;
@@ -378,7 +382,7 @@ var Perspectives = {
 					}
 					  
 				} catch (e) { 
-					Pers_debug.d_print("error", "exception: " + e); 
+					Pers_debug.d_print("error", "exception in notaryAjaxCallback: " + e);
 				} 
 			} else { // HTTP ERROR CODE
 				Pers_debug.d_print("error", 
@@ -945,36 +949,51 @@ var Perspectives = {
 		} 
 	}, 
 
+	// In Perspectives v4.0 the default settings were changed to check with notaries for *all* https websites,
+	// rather than only querying for sites that showed a certificate error.
+	// If the user has upgraded from an old version of Perspectives (<4.0) to a newer version (>=4.0),
+	// ask them if they would now prefer to check all https websites.
 	prompt_update: function() {
-		var ask_update = Perspectives.root_prefs.
-                getBoolPref("perspectives.prompt_update_all_https_setting");
-		if (ask_update == true) {
-			var check_good = Perspectives.root_prefs.
-					getBoolPref("perspectives.check_good_certificates");
-			if (!check_good) {
-				var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
-						.getService(Components.interfaces.nsIPromptService);
-				var check = {value:false};
-				var buttons = 
-						prompts.BUTTON_POS_0 * prompts.BUTTON_TITLE_IS_STRING
-						+ prompts.BUTTON_POS_1 * prompts.BUTTON_TITLE_IS_STRING;
-
-				var answer = prompts.confirmEx(null, "Perspectives update", 
-					"Thank you for using Perspectives. The default settings " +
-					"have been updated to query the notary server for all " + 
-					"HTTPS sites. Do you want to update this setting to use " +
-					"the default or keep your current settings?", buttons, 
-					"Update Settings", "Keep current settings", "", null, //TODO: localize
-					check);
-				if (answer == 0) {
-					Perspectives.root_prefs.
-						setBoolPref("perspectives.check_good_certificates", 
-									true); 
+		try {
+			//NOTE: Firefox pre-defines Cc and Ci, but SeaMonkey does not.
+			//We create local variables here so SeaMonkey clients don't throw 'variable is not defined' exceptions
+			const Cc = Components.classes, Ci = Components.interfaces;
+
+			//prompt_update_all_https_setting stores a value for "have we already asked the user about this?"
+			var ask_update = Perspectives.root_prefs.
+	                getBoolPref("perspectives.prompt_update_all_https_setting");
+			if (ask_update == true) {
+				var check_good = Perspectives.root_prefs.
+						getBoolPref("perspectives.check_good_certificates");
+				if (!check_good) {
+					var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+							.getService(Components.interfaces.nsIPromptService);
+					var check = {value:false};
+					var buttons =
+							prompts.BUTTON_POS_0 * prompts.BUTTON_TITLE_IS_STRING
+							+ prompts.BUTTON_POS_1 * prompts.BUTTON_TITLE_IS_STRING;
+
+					var answer = prompts.confirmEx(null, "Perspectives update",
+						"Thank you for using Perspectives. The default settings " +
+						"have been updated to query the notary server for all " +
+						"HTTPS sites. Do you want to update this setting to use " +
+						"the default or keep your current settings?", buttons,
+						"Update Settings", "Keep current settings", "", null, //TODO: localize
+						check);
+					if (answer == 0) {
+						Perspectives.root_prefs.
+							setBoolPref("perspectives.check_good_certificates",
+										true);
+					}
 				}
+				Perspectives.root_prefs.
+						setBoolPref("perspectives.prompt_update_all_https_setting",
+									false);
 			}
-			Perspectives.root_prefs.
-					setBoolPref("perspectives.prompt_update_all_https_setting",
-								false);
+		}
+		catch (e) {
+			Pers_debug.d_print("error", "Error: could not prompt to update preferences about check_good_certificates: " + e);
+			return null;
 		}
 	}
 			

-- 
perspectives-extension



More information about the Pkg-mozext-commits mailing list