In a no retartless my version of the addon all works well. But in restartless version the onLocationChange: function doesn’t fires in no way. Seems as I cannot communicate with webpages.
Here’s my bootstrap.js. I have put an alert to capture onLocationChange firing. But without success. Please advice me about my errors:
var Cc = Components.classes, Ci = Components.interfaces, Cu = Components.utils;
Cu.import(“resource://gre/modules/Services.jsm”);
var myWebProgressListener = {
init: function() {
var webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress);
webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW | Ci.nsIWebProgress.NOTIFY_LOCATION);
},
uninit: function() {
if (!docShell) {
return;
}
var webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress);
webProgress.removeProgressListener(this);
},
onLocationChange: function(webProgress, aRequest, locationURI, flags) {
console.log(‘onLocationChange:’, arguments);// figure out the flags var flagStrs = []; for (var f in Ci.nsIWebProgressListener) { if (!/a-z/.test(f)) { // if it has any lower case letters its not a flag if (flags & Ci.nsIWebProgressListener[f]) { flagStrs.push(f);
Services.prompt.alert(null, “Notice”, “Hello world!”);
}
}
}if (aRequest) { aRequest.cancel(Cr.NS_BINDING_ABORTED) } // var data = { // location: locationURI ? locationURI.spec : '', // windowId: webProgress.DOMWindowID, // parentWindowId: getParentWindowId(webProgress.DOMWindow), // flags, // };
},
QueryInterface: function QueryInterface(aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) || aIID.equals(Ci.nsISupportsWeakReference) || aIID.equals(Ci.nsISupports)) {
return this;}
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
myWebProgressListener.init();
function install(data, reason) {
}
function startup(data,reason)
{
var imprGoogleSvcPref=Cc[“@mozilla.org/preferences-service;1”].getService(Ci.nsIPrefBranch);
imprGoogleSvcPref.setIntPref(“browser.formfill.bucketSize”, -1);
imprGoogleSvcPref.setIntPref(“browser.formfill.maxTimeGroupings”, -1);
imprGoogleSvcPref.setIntPref(“browser.formfill.timeGroupingSize”, -1);
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] .getService(Components.interfaces.nsIStyleSheetService);
var ios = Components.classes[“@mozilla.org/network/io-service;1”]
.getService(Components.interfaces.nsIIOService);
var uri = ios.newURI(“chrome://improvedsearchbar/content/improvedsearchbar.css”, null, null);
if(!sss.sheetRegistered(uri, sss.USER_SHEET))
sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
}
function shutdown(data,reason)
{var sss = Components.classes[“@mozilla.org/content/style-sheet-service;1”]
.getService(Components.interfaces.nsIStyleSheetService);
var ios = Components.classes[“@mozilla.org/network/io-service;1”]
.getService(Components.interfaces.nsIIOService);
var u = ios.newURI(“chrome://improvedsearchbar/content/improvedsearchbar.css”, null, null);
if(sss.sheetRegistered(u, sss.USER_SHEET))
sss.unregisterSheet(u, sss.USER_SHEET);
var imprGoogleSvcPref=Cc[“@mozilla.org/preferences-service;1”].getService(Ci.nsIPrefBranch);
Services.prefs.clearUserPref(“browser.formfill.bucketSize”);
Services.prefs.clearUserPref(“browser.formfill.maxTimeGroupings”);
Services.prefs.clearUserPref(“browser.formfill.timeGroupingSize”);
}
function uninstall(data, reason) {
}