Most dog owners will tell you that their pets are loyal, socially intelligent animals.
And last month scientists in Japan showed domestic dogs avoid people they have seen behave unhelpfully to their owners, using a cunning test.
The experiment was designed to see whether dogs can evaluate humans interacting with one another over an object.
The result showed most dogs avoided taking food from someone they had seen behaving negatively to, which in this case means ignoring, their master.
During the test, dogs watched their owners try to retrieve a roll of tape from a sealed, transparent container, and then turn to an actor sitting next to them to request help.
In the first scenario the “nonhelper” actor refused to help and turned away.
In the second experiment, the “helper” held the container steady when asked for help, while the owner opened the lid and retrieved the object.
And in one further “control” test, the actor turned away but was not asked for help by the owner.
For each scenario, a neutral person sat on the other side of the owner, and did not interact in the activity.
Immediately afterwards, the actor and neutral person offered the dog food. Dogs tended to avoid the “nonhelper” actor, who had behaved badly to their owner, and more frequently took a treat from either the “helper”, the “control” actor or from the neutral person.
However the dogs did not take food more often from the "helper" compared with the "control" actor or neutral person.
Fifty-four dogs – from a variety of breeds – and their owners participated in the study, which was published in the journal Animal Behaviour in June this year.
Dogs’ avoidance of someone who had behaved negatively to their owner suggests they might understand third-party interactions, known as “social eavesdropping”.
Few non-primate animals are thought to eavesdrop. Another interesting example of the phenomenon is the bluestreak cleaner fish: bystanding fish prefer to stay close to “co-operative” cleaners than “cheaters” they have seen remove mucus and not parasites from host animals.
Humans are the most prolific social eavesdroppers. We often help one another for no obvious benefit. This helps us operate in what the research team call “large-scale co-operative societies”.
In humans, this sensitivity to interactions between others begins very early. Six-month-old babies can evaluate others based on their social behaviour, one study has suggested, showing preference to "helpful" over "nasty" characters.
It is known dogs are very sensitive to human actions directed at themselves, but it has been debated whether they are able to evaluate third-party interactions.
The new study adds to the evidence that they do just this.
The scientists point out the fact that the dogs’ owners were involved in the interaction could have influenced the result, writing: “Attachments between dogs and their owners can be strong, and the former may be particularly sensitive to how other people treat the latter.”
So if you’re a dog owner, you can take comfort in the idea that if someone is mean to you, you’ll have at least one “friend” by your side.
You can follow BBC Earth on Facebook, Twitter and Instagram.