Figure 4–14i. Spittlebug, order Hemiptera. Adult (left), nymph (right) secretes liquid and whips it into foam and stays inside. This is to protect from predators and also extreme temperature fluctuations.
spittlebug

Rob N Beth, Satish Nikam, Fickr  CC BY-NC-SA - 2.0