expandable foam does exactly what it says on the tin, Its going to look for the easiest root to freedom and that might not be where you had in mind for it to go
I have seen it used before in chassis to strenghten it but its easier to clean up on a bare shell than your fully trimmed car.
It sounds like its coming from the corner of the windscreen at the top it sounds like glass creaking or something tapping on glass and is only there when going over bumps so I dont know thanks John L.
i wouldn't use use the foam unless it's driving ya mad and it's the last resort .it has to be something simple rubbing spray some wd40 where you thing it's coming from
windscreen places just rip them off. could be fukt clip's.
prize it off and refit with silicone sealer.
if it persists hit windscreen with hammer
and hope they fit it better
this time.