It’s not possible to do a redirectTo from a nsIWebProgress listener?
If I go to non http uri:
[Exception… “Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsISupports.QueryInterface]” nsresult: “0x80004002 (NS_NOINTERFACE)” location: “JS frame :: Scratchpad/1 :: myExtension.onLocationChange :: line 9” data: no]
If I go to http uri like bing:
[Exception… “Component returned failure code: 0x804b000f (NS_ERROR_IN_PROGRESS) [nsIHttpChannel.redirectTo]” nsresult: “0x804b000f (NS_ERROR_IN_PROGRESS)” location: “JS frame :: Scratchpad/1 :: myExtension.onLocationChange :: line 10” data: no]
Here’s the copy paste code:
var myExtension = {
// nsIWebProgressListener
QueryInterface: XPCOMUtils.generateQI(["nsIWebProgressListener", "nsISupportsWeakReference"]),
onLocationChange: function(aProgress, aRequest, aURI) {
console.log(aURI.spec)
var httpChannel = aRequest.QueryInterface(Ci.nsIHttpChannel);
httpChannel.redirectTo(Services.io.newURI('data:text/html,blocked', null, null));
},
onStateChange: function() {},
onProgressChange: function() {},
onStatusChange: function() {},
onSecurityChange: function() {}
};
gBrowser.addProgressListener(myExtension);