Processes in which the treating agent is applied in the form of a foam