Means for preventing foam to leak out from the foaming device during foaming