Clean up interaction between onion authentication prompt (authPrompt.js) and about:neterror
Currently, when we get an onion authentication error we load "about:neterror" but show it as fake blank page using the "onionAuthPrompt" class.
Then if the user cancels the authentication prompt, we use insertFrameScript to show authentication neterror to show if the user cancels the prompt:
browser.messageManager.loadFrameScript(
`data:application/javascript,${encodeURIComponent(
`docShell.displayLoadError(${errorCode}, ${io}.newURI(${JSON.stringify(
uri.spec
)}), undefined, undefined);`
)}`,
false
);
This will reload the about:neterror page with the same error code, except the "onionAuthPrompt" will not be set. This relies on the failing channel being unset the second time around.
This all seems a bit hacky. It might be cleaner to communicating with NetErrorParent
to show the error when the prompt fails.
Alternatively, I wonder if we could make our onion prompt match up with the authentication prompts in firefox (promptAuth()
), which show before page load. And only enter "about:neterror" if it fails. It also looks quite different.
Our prompt:
Firefox prompt for basic authentication:
/cc @ma1 since this seems like something you would know a lot about.
/cc @donuts for the screenshot, in case you'd like to change our prompt.