I believe it's based on what the pack displays, if its grams then they show price per gram, if its ml, likewise.
I suppose its still possible to game with own label goods, from what I've observed it only seems to come up in a limited range of goods, sauces and suchlike.
I havent weighed a litre of oil, but a litre of water is a kg, so water based goods should be fairly comparable ml to g, that's the basis I work on anyway.