Are we sure origin was just syntactic sugar for URI.spec? We should be certain that we don't introduce a subtle bug here. I wonder what the new siteOrigin (https://bugzilla.mozilla.org/show_bug.cgi?id=1485177) would give us here. Maybe that's what we actually want?
Trac: Status: needs_review to needs_revision Keywords: TorBrowserTeam201909R deleted, TorBrowserTeam201909 added
if (firstPartyDomain === k_tb_about_uri_first_party_domain) {
would have ruled out the possibility of null URIs, but you're right, we should check that in general.
That code in the first link pointed me to a way to get the original URI that caused the error in (I think) a slightly less-hacky way: https://searchfox.org/mozilla-esr68/source/browser/base/content/browser-safebrowsing.js#10. It seems that when there is an error gBrowser.currentURI keeps the original URL, and gBrowser.selectedBrowser.documentURI (or the contentPrincipal) has the about:* one (gBrowser.currentURI is an alias of gBrowser.selectedBrowser.currentURI). This would have worked in esr60 too.