Pure water cannot foam — its surface film contracts and tears the bubbles apart. But seawater is full of proteins released by algae. They line up as two thin layers inside the bubble film itself, and then it stops tearing.
The foam a wave leaves behind
The bubble film of water
Proteins from algae
2 layers
of molecules is all it takes to hold the film together