This suggested the dogs were able to alter their behaviour when they knew their owners' perspective had changed.
The finding made researchers to conclude that dogs are more capable of understanding situations from a human's point of view than has previously been recognised.
The study, published in Animal Cognition, conducted tests on 84 dogs to find whether they could adapt their behaviour in response to the changed circumstances of their human owners.
The researchers wanted to see if dogs had a "flexible understanding" that could show they understood the viewpoint of a human.
It found that when the lights were turned off, dogs in a room with their human owners were much more likely to disobey and steal forbidden food.
The study was "incredible because it implies dogs understand the human can't see them, meaning they might understand the human perspective," said Dr Juliane Kaminski, from the University of Portsmouth's psychology department.
This could also be important in understanding the capacities of dogs that have to interact closely with humans, such as guide dogs for the blind and sniffer dogs, the researchers noted.