I've wondered about that. My impression of Corbyn's followers is that they won't be at all disheartened by an election loss... or by several, if it came to that. So if Corbyn wants to stay after a loss, he'll probably get to. Most leaders resign after a loss, but Kinnock didn't, for instance.
If I had to guess I'd guess that if Corbyn loses, he will stay on as leader and blame the loss on the party not being left wing enough. Then he'll spend the next parliament pushing the party as far to the left as he can.
Boris would quit if he loses, I suspect. Again guessing, but I doubt being PM has been as much fun as he thought it would be so he'd likely bow to the inevitable and throw his support behind somebody on the right.