Who sprays foam insulation over a junction box?

With plumbing and framing done, the next step is electrical work. Today I traced a circuit into the attic. Underneath some blown-in insulation, I found this. The flipper had used spray foam insulation on a junction box!

An attic junction box that has been covered with spray foam insulation.
An attic junction box that has been dug out of spray foam insulation.

I cut out the foam and open the box to inspect it.