Most legacy redirection extensions, including the WebExtensions API intended for this (if I'm not mistaken), make redirects in http-on-modify-request. But this way the original URL is recorded in history as well as the redirected URL.
To prevent the original URL from being recorded you need to use [nsIContentPolicy].shouldLoad. In e10s world it needs to be implmented in content process. The code is something like:
Code: Select all
shouldLoad: function (contentType, contentLocation, requestOrigin, node) {
let redirectUrl = this.getRedirectUrl(contentLocation.spec);
if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT && redirectUrl && node) {
node.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).loadURI(redirectUrl, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, requestOrigin, null, null);
return Ci.nsIContentPolicy.REJECT_REQUEST;
}
return Ci.nsIContentPolicy.ACCEPT;
}
But because of https://bugzilla.mozilla.org/show_bug.cgi?id=1331740, this doesn't work anymore, fails on node.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation). So now how could I get some reference of the tab/channel where the original request was made to then be able to call loadURI function?