I have seen this done many times before, but in the case of children, this can be a lesson that we do not want to teach our kids.
Currently, if you look around, I am pretty sure many households have realized that there is no longer a fear of doing things illegal. For example, stealing TV signals from an alternative source that will not lead to prosecution, or the infamous R4 DS chip, or even downloading of illegal files from the Internet. These have become so commonplace that many consider them a grey area.
Therefore, teaching the difference between right and wrong can be a difficult task. I am pretty sure that the children will figure out that the above mentioned activities are illegal. Furthermore, many children may already be doing the above activities without your knowledge.
I teach my kids that we must pay for the products before consuming them. I often will look around for a cashier that has no customers and pay for the kids treats there. There are also times that I will let the kids eat before paying, but I like many others know this is unethical.
Therefore, to answer the question of legality, I first will have to tell you what is considered theft in the eyes of a grocery store. Grocery stores are quite lenient when it comes to this issue.
A person who consumes a product without paying is stealing, but he/she will not be charged unless he/she leaves the store without paying. So, it is illegal to consume a product before purchasing.
Therefore, as long as the person is inside the store, he/she will not be prosecuted since he/she may pay for the product after finishing shopping. In the case of products that need to be weighed at the cash register, the culprit may just get banned from the store for purposely eating without paying.