I don't own a dog at the moment, but I remember when we had Smudge it annoyed me that people stroked first and asked later...
She was a brilliant dog, and would do anything NOT to hurt people, but really you should be asking before you stroke a random dog!
It's happened with my friend and her dog Penny too. We went out and we popped into a shop on the way back, so while she went in I waited outside with Penny for her. A little girl, maybe 3, ran up to Penny and just straight up started patting her face. Penny was full on whale eyeing the little girl and grumbling a little bit, so I pulled her behind me and asked the girl to stop politely. The mother went "Oh she won't hurt her, she knows how to pet dogs!" so I said "I'm not worried about your daughter hurting the dog, I'm worried about the dog hurting your daughter as she does not like being hit in the face!". The little girl was trying to fight around my legs to get to Penny, who was cowering behind me and grumbling slightly, and I was busy trying to stop her while arguing with her mother about how she needs to collect her daughter and stop her. It ended when the little girl shouted at Penny through my legs and Penny barked in response, the mother soon collected her daughter then!
I know the daughter didn't really know any better, but the mother should have... There's been a few times when kids have just run up to Penny and started petting her on the head/face first rather than asking and then stroking her nicely. Not all of the kids are really young either, or they don't look it at least. Some of them have looked maybe 8/9, early teens, etc..