Dogs have been dining on human food scraps since the early days of their domestication, a scientific study suggests.