Happens only with warrior class. Happens with anything if you have over 200 resistance to it. Not worth exploiting.
Also has to be an attack to cause the healing. Standing fire or like the fire/lava pits don't do anything. The real hot spots can still cause a tiny amount of damage or the big droids can still cause like 1 damage periodically.
If you drink a healing potion or sleep your HP reset back.
Interesting. I figured this was well known by now. All other classes just negate the damage. Warriors become healed just like other enemies do like red dragons being hit by a fire attack.
Fyi, I've not tested it with anything else other then fire and shock. Stumbled on it years ago gearing up for the Ark with shock ward and gearing up for fire protection for the fire elemental plane and mad wizards.