Spray foam between the roof and interior supports

I was watching a program on TV an I saw that the host had used an expanding spray foam between the interior supporting structure and the roof. My guess is that they used it as a supporting cushion between the interior brace and roof to remove some of the flex or possibly as extra sound deadening. Looks like the factory used some type of adhesive, which in my car has separated over the years. Has anyone else used this type of method?

Guess you would have to place dikes to keep the product in the area you want it to stay in since before it sets up it would rain or flow downward over the rear wheel well and the lower quarter panel Of course you will have to cut and shape it once it sets up and there is the chance that it would promote rusting of these areas now since it would reduce ventilation and circulation

Have a race car where they used the stuff to seal off the rear of the car from the passenger cockpit. Of course looks like Cr**

For me - nope would not even consider it even on my heavily modified cars