I'm not sure this origin calculation works when on device, especially the location.port part.

getting the origin at startup using mozApps.getSelf(), and just retrieving it here, could also be more reliable
(but I don't know if this works correctly in the browser though, have to test it)